diff options
author | Colin Snover | 2017-02-25 18:13:55 -0600 |
---|---|---|
committer | Colin Snover | 2017-04-23 13:07:25 -0500 |
commit | f3db412d6f3dd90893eb90a084491b90acdddc9e (patch) | |
tree | 0285436046d7dad038c92f9105866a37454c3ce8 /engines/sci/video | |
parent | a799cb3462a220afcd705c74291075f98520d87c (diff) | |
download | scummvm-rg350-f3db412d6f3dd90893eb90a084491b90acdddc9e.tar.gz scummvm-rg350-f3db412d6f3dd90893eb90a084491b90acdddc9e.tar.bz2 scummvm-rg350-f3db412d6f3dd90893eb90a084491b90acdddc9e.zip |
SCI32: Serialize Robots in SCI3
This is necessary for at least Lighthouse, which maintains the
state of Robots across save games.
Diffstat (limited to 'engines/sci/video')
-rw-r--r-- | engines/sci/video/robot_decoder.cpp | 17 | ||||
-rw-r--r-- | engines/sci/video/robot_decoder.h | 46 |
2 files changed, 50 insertions, 13 deletions
diff --git a/engines/sci/video/robot_decoder.cpp b/engines/sci/video/robot_decoder.cpp index ba8a4683dd..6a4e912218 100644 --- a/engines/sci/video/robot_decoder.cpp +++ b/engines/sci/video/robot_decoder.cpp @@ -371,6 +371,8 @@ void RobotDecoder::initStream(const GuiResourceId robotId) { error("Unable to open robot file %s", fileName.c_str()); } + _robotId = robotId; + const uint16 id = stream->readUint16LE(); if (id != 0x16) { error("Invalid robot file %s", fileName.c_str()); @@ -437,17 +439,16 @@ void RobotDecoder::initAudio() { void RobotDecoder::initVideo(const int16 x, const int16 y, const int16 scale, const reg_t plane, const bool hasPalette, const uint16 paletteSize) { _position = Common::Point(x, y); - if (scale != 128) { - _scaleInfo.x = scale; - _scaleInfo.y = scale; - _scaleInfo.signal = kScaleSignalManual; - } + _scaleInfo.x = scale; + _scaleInfo.y = scale; + _scaleInfo.signal = scale == 128 ? kScaleSignalNone : kScaleSignalManual; _plane = g_sci->_gfxFrameout->getPlanes().findByObject(plane); if (_plane == nullptr) { error("Invalid plane %04x:%04x passed to RobotDecoder::open", PRINT_REG(plane)); } + _planeId = plane; _minFrameRate = _frameRate - kMaxFrameRateDrift; _maxFrameRate = _frameRate + kMaxFrameRateDrift; @@ -585,6 +586,8 @@ void RobotDecoder::close() { debugC(kDebugLevelVideo, "Closing robot"); + _robotId = -1; + _planeId = NULL_REG; _status = kRobotStatusUninitialized; _videoSizes.clear(); _recordPositions.clear(); @@ -1343,6 +1346,10 @@ void RobotDecoder::expandCel(byte* target, const byte* source, const int16 celWi } } +int16 RobotDecoder::getPriority() const { + return _priority; +} + void RobotDecoder::setPriority(const int16 newPriority) { _priority = newPriority; } diff --git a/engines/sci/video/robot_decoder.h b/engines/sci/video/robot_decoder.h index 9d8c720968..aa1d9da75c 100644 --- a/engines/sci/video/robot_decoder.h +++ b/engines/sci/video/robot_decoder.h @@ -469,23 +469,25 @@ public: #pragma mark RobotDecoder /** - * RobotDecoder implements the logic required - * for Robot animations. - * - * @note A paused or finished RobotDecoder was - * classified as serializable in SCI3, but the - * save/load code would attempt to use uninitialised - * values, so it seems that robots were not ever - * actually able to be saved. + * RobotDecoder implements the logic required for Robot animations. */ class RobotDecoder { public: RobotDecoder(SegManager *segMan); ~RobotDecoder(); + GuiResourceId getResourceId() const { + return _robotId; + } + private: SegManager *_segMan; + /** + * The ID of the currently loaded robot. + */ + GuiResourceId _robotId; + #pragma mark Constants public: /** @@ -1175,6 +1177,27 @@ private: #pragma mark Rendering public: /** + * Gets the plane used to render the robot. + */ + const reg_t getPlaneId() const { + return _planeId; + } + + /** + * Gets the origin of the robot. + */ + Common::Point getPosition() const { + return _position; + } + + /** + * Gets the scale of the robot. + */ + int16 getScale() const { + return _scaleInfo.x; + } + + /** * Puts the current dimensions of the robot, in game script * coordinates, into the given rect, and returns the total * number of frames in the robot animation. @@ -1207,6 +1230,8 @@ public: */ void expandCel(byte *target, const byte* source, const int16 celWidth, const int16 celHeight) const; + int16 getPriority() const; + /** * Sets the visual priority of the robot. * @see Plane::_priority @@ -1292,6 +1317,11 @@ private: DecompressorLZS _decompressor; /** + * The ID of the robot plane. + */ + reg_t _planeId; + + /** * The origin of the robot animation, in screen * coordinates. */ |