From e17fdb5aaba0c4a4482367282fdc1df56f4b6115 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 2 Mar 2014 11:41:46 -0500 Subject: MADS: Actually added new animation files --- engines/mads/animation.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 engines/mads/animation.cpp (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp new file mode 100644 index 0000000000..f5144c3c49 --- /dev/null +++ b/engines/mads/animation.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public 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 "mads/animation.h" + +namespace MADS { + +Animation *Animation::init(MADSEngine *vm, Scene *scene) { + return new Animation(vm, scene); +} + +void Animation::load(MSurface *sceneSurface, MSurface *interfaceSurface, int sceneId, + int flags, byte *palette, SceneInfo *sceneInfo) { + +} + + +} // End of namespace MADS -- cgit v1.2.3 From cc810add7479b024138f31fc559f5a9cf7f7a459 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 2 Mar 2014 16:42:39 -0500 Subject: MADS: In progress implementing animation loader --- engines/mads/animation.cpp | 242 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 240 insertions(+), 2 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index f5144c3c49..dd62e7b0f0 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -21,17 +21,255 @@ */ #include "mads/animation.h" +#include "mads/compression.h" + +#define FILENAME_SIZE 64 namespace MADS { + +AAHeader::AAHeader(Common::SeekableReadStream *f) { + _spriteListCount = f->readUint16LE(); + _miscEntriesCount = f->readUint16LE(); + _frameEntriesCount = f->readUint16LE(); + _messagesCount = f->readUint16LE(); + f->skip(1); + _flags = f->readByte(); + + f->skip(2); + _animMode = f->readUint16LE(); + _roomNumber = f->readUint16LE(); + f->skip(2); + _field12 = f->readUint16LE() != 0; + _spriteListIndex = f->readUint16LE(); + _scrollPosition.x = f->readSint16LE(); + _scrollPosition.y = f->readSint16LE(); + _scrollTicks = f->readUint16LE(); + f->skip(8); + + char buffer[FILENAME_SIZE]; + f->read(buffer, FILENAME_SIZE); + buffer[FILENAME_SIZE] = '\0'; + _interfaceFile = Common::String(buffer); + + for (int i = 0; i < 10; ++i) { + f->read(buffer, FILENAME_SIZE); + buffer[FILENAME_SIZE] = '\0'; + _spriteSetNames[i] = Common::String(buffer); + } + + f->skip(81); + f->read(buffer, FILENAME_SIZE); + buffer[FILENAME_SIZE] = '\0'; + _lbmFilename = Common::String(buffer); + + f->skip(365); + f->read(buffer, FILENAME_SIZE); + buffer[FILENAME_SIZE] = '\0'; + _spritesFilename = Common::String(buffer); + + f->skip(48); + f->read(buffer, FILENAME_SIZE); + buffer[FILENAME_SIZE] = '\0'; + _soundName = Common::String(buffer); + + f->skip(13); + f->read(buffer, FILENAME_SIZE); + buffer[FILENAME_SIZE] = '\0'; + _dsrName = Common::String(buffer); + + f->read(buffer, FILENAME_SIZE); + buffer[FILENAME_SIZE] = '\0'; + Common::String fontResource(buffer); +} + +/*------------------------------------------------------------------------*/ + +void AnimMessage::load(Common::SeekableReadStream *f) { + _soundId = f->readSint16LE(); + + char buffer[64]; + f->read(&buffer[0], 64); + _msg = Common::String(buffer); + f->skip(4); + _pos.x = f->readSint16LE(); + _pos.y = f->readSint16LE(); + _flags = f->readUint16LE(); + _rgb1[0] = f->readByte() << 2; + _rgb1[1] = f->readByte() << 2; + _rgb1[2] = f->readByte() << 2; + _rgb2[0] = f->readByte() << 2; + _rgb2[1] = f->readByte() << 2; + _rgb2[2] = f->readByte() << 2; + f->skip(2); // Space for kernelMsgIndex + _kernelMsgIndex = -1; + f->skip(6); + _startFrame = f->readUint16LE(); + _endFrame = f->readUint16LE(); + f->skip(2); +} + +void AnimFrameEntry::load(Common::SeekableReadStream *f) { + _frameNumber = f->readUint16LE(); + _seqIndex = f->readByte(); + _spriteSlot._spritesIndex = f->readByte(); + _spriteSlot._frameNumber = f->readUint16LE(); + _spriteSlot._position.x = f->readSint16LE(); + _spriteSlot._position.y = f->readSint16LE(); + _spriteSlot._depth = f->readSByte(); + _spriteSlot._scale = (int8)f->readByte(); +} + +/*------------------------------------------------------------------------*/ + +void AnimMiscEntry::load(Common::SeekableReadStream *f) { + _soundId = f->readByte(); + _msgIndex = f->readSByte(); + _numTicks = f->readUint16LE(); + _posAdjust.x = f->readSint16LE(); + _posAdjust.y = f->readSint16LE(); + _scrollPos.x = f->readSint16LE(); + _scrollPos.y = f->readSint16LE(); +} + +/*------------------------------------------------------------------------*/ Animation *Animation::init(MADSEngine *vm, Scene *scene) { return new Animation(vm, scene); } -void Animation::load(MSurface *sceneSurface, MSurface *interfaceSurface, int sceneId, - int flags, byte *palette, SceneInfo *sceneInfo) { +void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, + const Common::String &resName, int flags, Common::Array *palAnimData, + SceneInfo *sceneInfo) { + Common::String resourceName = resName; + if (!resourceName.contains(".")) + resourceName += ".AA"; + + File f(resourceName); + MadsPack madsPack(&f); + Common::SeekableReadStream *stream = madsPack.getItemStream(0); + AAHeader aaHeader(stream); + delete stream; + + if (aaHeader._animMode == 4) + flags |= 0x4000; + + if (flags & 0x100) { + loadInterface(interfaceSurface, depthSurface, aaHeader, flags, palAnimData, sceneInfo); + } + if (flags & 0x200) { + // No data + aaHeader._messagesCount = 0; + aaHeader._frameEntriesCount = 0; + aaHeader._miscEntriesCount = 0; + } + + // Initialize the reference list + for (int i = 0; i < aaHeader._spriteListCount; ++i) + _spriteListIndexes.push_back(-1); + + if (aaHeader._messagesCount > 0) { + // Chunk 2: Following is a list of any messages for the animation + Common::SeekableReadStream *msgStream = madsPack.getItemStream(1); + + for (int i = 0; i < aaHeader._messagesCount; ++i) { + AnimMessage rec; + rec.load(msgStream); + _messages.push_back(rec); + } + + delete msgStream; + } + + if (aaHeader._frameEntriesCount > 0) { + // Chunk 3: animation frame info + Common::SeekableReadStream *frameStream = madsPack.getItemStream(2); + + for (int i = 0; i < aaHeader._frameEntriesCount; i++) { + AnimFrameEntry rec; + rec.load(frameStream); + _frameEntries.push_back(rec); + } + + delete frameStream; + } + + if (aaHeader._miscEntriesCount > 0) { + // Chunk 4: Misc Data + Common::SeekableReadStream *miscStream = madsPack.getItemStream(3); + + for (int i = 0; i < aaHeader._miscEntriesCount; ++i) { + AnimMiscEntry rec; + rec.load(miscStream); + _miscEntries.push_back(rec); + } + + delete miscStream; + } + /* + // If the animation specifies a font, then load it for access + if (_flags & ANIM_CUSTOM_FONT) { + Common::String fontName; + if (madsRes) + fontName += "*"; + fontName += fontResource; + + if (fontName != "") + _font = _vm->_font->getFont(fontName.c_str()); + else + warning("Attempted to set a font with an empty name"); + } + + // If a speech file is specified, then load it + if (!_dsrName.empty()) + _vm->_sound->loadDSRFile(_dsrName.c_str()); + + // Load all the sprite sets for the animation + for (int i = 0; i < spriteListCount; ++i) { + if (_field12 && (i == _spriteListIndex)) + // Skip over field, since it's manually loaded + continue; + + _spriteListIndexes[i] = _view->_spriteSlots.addSprites(_spriteSetNames[i].c_str()); + } + + + if (_field12) { + Common::String resName; + if (madsRes) + resName += "*"; + resName += _spriteSetNames[_spriteListIndex]; + + _spriteListIndexes[_spriteListIndex] = _view->_spriteSlots.addSprites(resName.c_str()); + } + */ + f.close(); } +void Animation::loadInterface(InterfaceSurface &interfaceSurface, MSurface &depthSurface, + AAHeader &header, int flags, Common::Array *palAnimData, SceneInfo *sceneInfo) { + _scene->_depthStyle = 0; + if (header._animMode <= 2) { + sceneInfo->load(header._roomNumber, flags, header._interfaceFile, 0, depthSurface, interfaceSurface); + _scene->_depthStyle = sceneInfo->_depthStyle == 2 ? 1 : 0; + if (palAnimData) { + palAnimData->clear(); + for (uint i = 0; i < sceneInfo->_palAnimData.size(); ++i) + palAnimData->push_back(sceneInfo->_palAnimData[i]); + } + } + else if (header._animMode == 4) { + // Load a scene interface + Common::String resourceName = "*" + header._interfaceFile; + interfaceSurface.load(_vm, resourceName); + + if (palAnimData) + palAnimData->clear(); + } + else { + // Original has useless code here + } +} + } // End of namespace MADS -- cgit v1.2.3 From d5b5cbbb686596f50cdb9ea072c9178775ada720 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 2 Mar 2014 17:49:52 -0500 Subject: MADS: Implemented rest of animation loading --- engines/mads/animation.cpp | 88 ++++++++++++++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 31 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index dd62e7b0f0..339ee72d46 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -39,7 +39,7 @@ AAHeader::AAHeader(Common::SeekableReadStream *f) { _animMode = f->readUint16LE(); _roomNumber = f->readUint16LE(); f->skip(2); - _field12 = f->readUint16LE() != 0; + _manualFlag = f->readUint16LE() != 0; _spriteListIndex = f->readUint16LE(); _scrollPosition.x = f->readSint16LE(); _scrollPosition.y = f->readSint16LE(); @@ -137,9 +137,19 @@ Animation *Animation::init(MADSEngine *vm, Scene *scene) { return new Animation(vm, scene); } +Animation::Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) { + _font = nullptr; +} + +Animation::~Animation() { + delete _font; + for (uint i = 0; i < _spriteSets.size(); ++i) + delete _spriteSets[i]; +} + void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, - const Common::String &resName, int flags, Common::Array *palAnimData, - SceneInfo *sceneInfo) { + const Common::String &resName, int flags, Common::Array *palAnimData, + SceneInfo *sceneInfo) { Common::String resourceName = resName; if (!resourceName.contains(".")) resourceName += ".AA"; @@ -165,9 +175,11 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, } // Initialize the reference list + _spriteListIndexes.clear(); for (int i = 0; i < aaHeader._spriteListCount; ++i) _spriteListIndexes.push_back(-1); + _messages.clear(); if (aaHeader._messagesCount > 0) { // Chunk 2: Following is a list of any messages for the animation Common::SeekableReadStream *msgStream = madsPack.getItemStream(1); @@ -181,6 +193,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, delete msgStream; } + _frameEntries.clear(); if (aaHeader._frameEntriesCount > 0) { // Chunk 3: animation frame info Common::SeekableReadStream *frameStream = madsPack.getItemStream(2); @@ -194,6 +207,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, delete frameStream; } + _miscEntries.clear(); if (aaHeader._miscEntriesCount > 0) { // Chunk 4: Misc Data Common::SeekableReadStream *miscStream = madsPack.getItemStream(3); @@ -206,43 +220,55 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, delete miscStream; } - /* + // If the animation specifies a font, then load it for access - if (_flags & ANIM_CUSTOM_FONT) { - Common::String fontName; - if (madsRes) - fontName += "*"; - fontName += fontResource; - - if (fontName != "") - _font = _vm->_font->getFont(fontName.c_str()); - else - warning("Attempted to set a font with an empty name"); + delete _font; + if (aaHeader._flags & ANIM_CUSTOM_FONT) { + Common::String fontName = "*" + aaHeader._fontResource; + _font = _vm->_font->getFont(fontName.c_str()); + } else { + _font = nullptr; } - - // If a speech file is specified, then load it - if (!_dsrName.empty()) - _vm->_sound->loadDSRFile(_dsrName.c_str()); - + // Load all the sprite sets for the animation - for (int i = 0; i < spriteListCount; ++i) { - if (_field12 && (i == _spriteListIndex)) - // Skip over field, since it's manually loaded - continue; + for (uint i = 0; i < _spriteSets.size(); ++i) + delete _spriteSets[i]; + _spriteSets.clear(); + _spriteSets.resize(aaHeader._spriteListCount); - _spriteListIndexes[i] = _view->_spriteSlots.addSprites(_spriteSetNames[i].c_str()); + for (int i = 0; i < aaHeader._spriteListCount; ++i) { + if (aaHeader._manualFlag && (i == aaHeader._spriteListIndex)) { + // Skip over field, since it's manually loaded + _spriteSets[i] = nullptr; + } else { + _spriteSets[i] = new SpriteAsset(_vm, aaHeader._spriteSetNames[i], flags); + } } + if (aaHeader._manualFlag) { + Common::String resName = "*" + aaHeader._spriteSetNames[aaHeader._spriteListIndex]; + SpriteAsset *sprites = new SpriteAsset(_vm, resName, flags); + _spriteSets[aaHeader._spriteListIndex] = sprites; + + _spriteListIndexes[aaHeader._spriteListIndex] = _scene->_sprites.add(sprites); + } - if (_field12) { - Common::String resName; - if (madsRes) - resName += "*"; - resName += _spriteSetNames[_spriteListIndex]; + // TODO: List var_420/var_422 population that seems to overwrite other structures? - _spriteListIndexes[_spriteListIndex] = _view->_spriteSlots.addSprites(resName.c_str()); + if (aaHeader._animMode == 4) { + // Remaps the sprite list indexes for frames to the loaded sprite list indexes + for (uint i = 0; i < _frameEntries.size(); ++i) { + int spriteListIndex = _frameEntries[i]._spriteSlot._spritesIndex; + _frameEntries[i]._spriteSlot._spritesIndex = _spriteListIndexes[spriteListIndex]; + } + } else { + // Remaps the sprite list indexes for frames to the loaded sprite list indexes + for (uint i = 0; i < _frameEntries.size(); ++i) { + int spriteListIndex = _frameEntries[i]._spriteSlot._spritesIndex; + _frameEntries[i]._spriteSlot._spritesIndex = _spriteListIndexes[spriteListIndex]; + } } - */ + f.close(); } -- cgit v1.2.3 From 4931c8257df6d5dbc3d7fa1bc2b85f859cec17d9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 2 Mar 2014 18:37:09 -0500 Subject: MADS: Further animation loading and final section of scene loading code --- engines/mads/animation.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 339ee72d46..ebb2289443 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -23,12 +23,12 @@ #include "mads/animation.h" #include "mads/compression.h" -#define FILENAME_SIZE 64 +#define FILENAME_SIZE 13 namespace MADS { AAHeader::AAHeader(Common::SeekableReadStream *f) { - _spriteListCount = f->readUint16LE(); + _spriteSetsCount = f->readUint16LE(); _miscEntriesCount = f->readUint16LE(); _frameEntriesCount = f->readUint16LE(); _messagesCount = f->readUint16LE(); @@ -43,43 +43,43 @@ AAHeader::AAHeader(Common::SeekableReadStream *f) { _spriteListIndex = f->readUint16LE(); _scrollPosition.x = f->readSint16LE(); _scrollPosition.y = f->readSint16LE(); - _scrollTicks = f->readUint16LE(); - f->skip(8); + _scrollTicks = f->readUint32LE(); + f->skip(6); char buffer[FILENAME_SIZE]; f->read(buffer, FILENAME_SIZE); - buffer[FILENAME_SIZE] = '\0'; + buffer[FILENAME_SIZE - 1] = '\0'; _interfaceFile = Common::String(buffer); for (int i = 0; i < 10; ++i) { f->read(buffer, FILENAME_SIZE); - buffer[FILENAME_SIZE] = '\0'; - _spriteSetNames[i] = Common::String(buffer); + buffer[FILENAME_SIZE - 1] = '\0'; + _spriteSetNames.push_back(Common::String(buffer)); } f->skip(81); f->read(buffer, FILENAME_SIZE); - buffer[FILENAME_SIZE] = '\0'; + buffer[FILENAME_SIZE - 1] = '\0'; _lbmFilename = Common::String(buffer); f->skip(365); f->read(buffer, FILENAME_SIZE); - buffer[FILENAME_SIZE] = '\0'; + buffer[FILENAME_SIZE - 1] = '\0'; _spritesFilename = Common::String(buffer); f->skip(48); f->read(buffer, FILENAME_SIZE); - buffer[FILENAME_SIZE] = '\0'; + buffer[FILENAME_SIZE - 1] = '\0'; _soundName = Common::String(buffer); f->skip(13); f->read(buffer, FILENAME_SIZE); - buffer[FILENAME_SIZE] = '\0'; + buffer[FILENAME_SIZE - 1] = '\0'; _dsrName = Common::String(buffer); f->read(buffer, FILENAME_SIZE); - buffer[FILENAME_SIZE] = '\0'; - Common::String fontResource(buffer); + buffer[FILENAME_SIZE - 1] = '\0'; + _fontResource = Common::String(buffer); } /*------------------------------------------------------------------------*/ @@ -176,7 +176,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, // Initialize the reference list _spriteListIndexes.clear(); - for (int i = 0; i < aaHeader._spriteListCount; ++i) + for (int i = 0; i < aaHeader._spriteSetsCount; ++i) _spriteListIndexes.push_back(-1); _messages.clear(); @@ -234,9 +234,9 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, for (uint i = 0; i < _spriteSets.size(); ++i) delete _spriteSets[i]; _spriteSets.clear(); - _spriteSets.resize(aaHeader._spriteListCount); + _spriteSets.resize(aaHeader._spriteSetsCount); - for (int i = 0; i < aaHeader._spriteListCount; ++i) { + for (int i = 0; i < aaHeader._spriteSetsCount; ++i) { if (aaHeader._manualFlag && (i == aaHeader._spriteListIndex)) { // Skip over field, since it's manually loaded _spriteSets[i] = nullptr; @@ -272,7 +272,6 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, f.close(); } - void Animation::loadInterface(InterfaceSurface &interfaceSurface, MSurface &depthSurface, AAHeader &header, int flags, Common::Array *palAnimData, SceneInfo *sceneInfo) { _scene->_depthStyle = 0; -- cgit v1.2.3 From 3a842a079c668e9dfc52a6056119d4932e8ef56d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 2 Mar 2014 23:09:17 -0500 Subject: MADS: Bulk of implementation of ScreenObjects::check --- engines/mads/animation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index ebb2289443..8ea95ee168 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -287,7 +287,7 @@ void Animation::loadInterface(InterfaceSurface &interfaceSurface, MSurface &dept else if (header._animMode == 4) { // Load a scene interface Common::String resourceName = "*" + header._interfaceFile; - interfaceSurface.load(_vm, resourceName); + interfaceSurface.load(resourceName); if (palAnimData) palAnimData->clear(); -- cgit v1.2.3 From 9e356dd945863a4c4dfa89f2a94dd1a56c2d03a6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 3 Mar 2014 23:40:23 -0500 Subject: MADS: Implemented extra message and dirty area classes --- engines/mads/animation.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 8ea95ee168..0546fc3d34 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -297,4 +297,8 @@ void Animation::loadInterface(InterfaceSurface &interfaceSurface, MSurface &dept } } +void Animation::update() { + warning("TODO: Animation::update"); +} + } // End of namespace MADS -- cgit v1.2.3 From f6888eef1069ac5df07c3f4dcc3a30755bc4ebb0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 4 Mar 2014 09:33:57 -0500 Subject: MADS: Implementation of timer functionality for Scene::doFrame --- engines/mads/animation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 0546fc3d34..941533fa63 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -179,7 +179,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, for (int i = 0; i < aaHeader._spriteSetsCount; ++i) _spriteListIndexes.push_back(-1); - _messages.clear(); + _kernelMessages.clear(); if (aaHeader._messagesCount > 0) { // Chunk 2: Following is a list of any messages for the animation Common::SeekableReadStream *msgStream = madsPack.getItemStream(1); @@ -187,7 +187,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, for (int i = 0; i < aaHeader._messagesCount; ++i) { AnimMessage rec; rec.load(msgStream); - _messages.push_back(rec); + _kernelMessages.push_back(rec); } delete msgStream; -- cgit v1.2.3 From 1607a9104700e987cacfec41aaafd25d979aeb98 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 4 Mar 2014 20:06:48 -0500 Subject: MADS: Finished remainder of Scene::doFrame --- engines/mads/animation.cpp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 941533fa63..c97d707f39 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -139,6 +139,7 @@ Animation *Animation::init(MADSEngine *vm, Scene *scene) { Animation::Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) { _font = nullptr; + _resetFlag = false; } Animation::~Animation() { @@ -147,6 +148,31 @@ Animation::~Animation() { delete _spriteSets[i]; } +void Animation::free() { + Scene &scene = _vm->_game->_scene; + Player &player = _vm->_game->_player; + + if (!scene._freeAnimationFlag) { + scene._spriteSlots.fullRefresh(true); + scene._sequences.scan(); + } + + // Refresh the player + if (player._visible) { + player._forceRefresh = true; + player.update(); + } + + // Remove any kernel messages in use by the animation + for (uint i = 0; i < _messages.size(); ++i) { + int msgIndex = _messages[i]._kernelMsgIndex; + scene._kernelMessages.remove(msgIndex); + } + + _resetFlag = false; + delete this; +} + void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, const Common::String &resName, int flags, Common::Array *palAnimData, SceneInfo *sceneInfo) { @@ -179,7 +205,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, for (int i = 0; i < aaHeader._spriteSetsCount; ++i) _spriteListIndexes.push_back(-1); - _kernelMessages.clear(); + _messages.clear(); if (aaHeader._messagesCount > 0) { // Chunk 2: Following is a list of any messages for the animation Common::SeekableReadStream *msgStream = madsPack.getItemStream(1); @@ -187,7 +213,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, for (int i = 0; i < aaHeader._messagesCount; ++i) { AnimMessage rec; rec.load(msgStream); - _kernelMessages.push_back(rec); + _messages.push_back(rec); } delete msgStream; -- cgit v1.2.3 From a0e955d8d327afa83ad96fe1ce765eeba0ce561f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 5 Mar 2014 20:45:02 -0500 Subject: MADS: More Animation class implementation --- engines/mads/animation.cpp | 255 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 228 insertions(+), 27 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index c97d707f39..d0c7d3079b 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -27,7 +27,7 @@ namespace MADS { -AAHeader::AAHeader(Common::SeekableReadStream *f) { +void AAHeader::load(Common::SeekableReadStream *f) { _spriteSetsCount = f->readUint16LE(); _miscEntriesCount = f->readUint16LE(); _frameEntriesCount = f->readUint16LE(); @@ -40,7 +40,7 @@ AAHeader::AAHeader(Common::SeekableReadStream *f) { _roomNumber = f->readUint16LE(); f->skip(2); _manualFlag = f->readUint16LE() != 0; - _spriteListIndex = f->readUint16LE(); + _spritesIndex = f->readUint16LE(); _scrollPosition.x = f->readSint16LE(); _scrollPosition.y = f->readSint16LE(); _scrollTicks = f->readUint32LE(); @@ -184,33 +184,33 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, MadsPack madsPack(&f); Common::SeekableReadStream *stream = madsPack.getItemStream(0); - AAHeader aaHeader(stream); + _header.load(stream); delete stream; - if (aaHeader._animMode == 4) + if (_header._animMode == 4) flags |= 0x4000; if (flags & 0x100) { - loadInterface(interfaceSurface, depthSurface, aaHeader, flags, palAnimData, sceneInfo); + loadInterface(interfaceSurface, depthSurface, _header, flags, palAnimData, sceneInfo); } if (flags & 0x200) { // No data - aaHeader._messagesCount = 0; - aaHeader._frameEntriesCount = 0; - aaHeader._miscEntriesCount = 0; + _header._messagesCount = 0; + _header._frameEntriesCount = 0; + _header._miscEntriesCount = 0; } // Initialize the reference list _spriteListIndexes.clear(); - for (int i = 0; i < aaHeader._spriteSetsCount; ++i) + for (int i = 0; i < _header._spriteSetsCount; ++i) _spriteListIndexes.push_back(-1); _messages.clear(); - if (aaHeader._messagesCount > 0) { + if (_header._messagesCount > 0) { // Chunk 2: Following is a list of any messages for the animation Common::SeekableReadStream *msgStream = madsPack.getItemStream(1); - for (int i = 0; i < aaHeader._messagesCount; ++i) { + for (int i = 0; i < _header._messagesCount; ++i) { AnimMessage rec; rec.load(msgStream); _messages.push_back(rec); @@ -220,11 +220,11 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, } _frameEntries.clear(); - if (aaHeader._frameEntriesCount > 0) { + if (_header._frameEntriesCount > 0) { // Chunk 3: animation frame info Common::SeekableReadStream *frameStream = madsPack.getItemStream(2); - for (int i = 0; i < aaHeader._frameEntriesCount; i++) { + for (int i = 0; i < _header._frameEntriesCount; i++) { AnimFrameEntry rec; rec.load(frameStream); _frameEntries.push_back(rec); @@ -234,11 +234,11 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, } _miscEntries.clear(); - if (aaHeader._miscEntriesCount > 0) { + if (_header._miscEntriesCount > 0) { // Chunk 4: Misc Data Common::SeekableReadStream *miscStream = madsPack.getItemStream(3); - for (int i = 0; i < aaHeader._miscEntriesCount; ++i) { + for (int i = 0; i < _header._miscEntriesCount; ++i) { AnimMiscEntry rec; rec.load(miscStream); _miscEntries.push_back(rec); @@ -249,8 +249,8 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, // If the animation specifies a font, then load it for access delete _font; - if (aaHeader._flags & ANIM_CUSTOM_FONT) { - Common::String fontName = "*" + aaHeader._fontResource; + if (_header._flags & ANIM_CUSTOM_FONT) { + Common::String fontName = "*" + _header._fontResource; _font = _vm->_font->getFont(fontName.c_str()); } else { _font = nullptr; @@ -260,28 +260,28 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, for (uint i = 0; i < _spriteSets.size(); ++i) delete _spriteSets[i]; _spriteSets.clear(); - _spriteSets.resize(aaHeader._spriteSetsCount); + _spriteSets.resize(_header._spriteSetsCount); - for (int i = 0; i < aaHeader._spriteSetsCount; ++i) { - if (aaHeader._manualFlag && (i == aaHeader._spriteListIndex)) { + for (int i = 0; i < _header._spriteSetsCount; ++i) { + if (_header._manualFlag && (i == _header._spritesIndex)) { // Skip over field, since it's manually loaded _spriteSets[i] = nullptr; } else { - _spriteSets[i] = new SpriteAsset(_vm, aaHeader._spriteSetNames[i], flags); + _spriteSets[i] = new SpriteAsset(_vm, _header._spriteSetNames[i], flags); } } - if (aaHeader._manualFlag) { - Common::String resName = "*" + aaHeader._spriteSetNames[aaHeader._spriteListIndex]; + if (_header._manualFlag) { + Common::String resName = "*" + _header._spriteSetNames[_header._spritesIndex]; SpriteAsset *sprites = new SpriteAsset(_vm, resName, flags); - _spriteSets[aaHeader._spriteListIndex] = sprites; + _spriteSets[_header._spritesIndex] = sprites; - _spriteListIndexes[aaHeader._spriteListIndex] = _scene->_sprites.add(sprites); + _spriteListIndexes[_header._spritesIndex] = _scene->_sprites.add(sprites); } // TODO: List var_420/var_422 population that seems to overwrite other structures? - if (aaHeader._animMode == 4) { + if (_header._animMode == 4) { // Remaps the sprite list indexes for frames to the loaded sprite list indexes for (uint i = 0; i < _frameEntries.size(); ++i) { int spriteListIndex = _frameEntries[i]._spriteSlot._spritesIndex; @@ -298,6 +298,33 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, f.close(); } +void Animation::loadFrame(int frameNumber) { + Scene &scene = _vm->_game->_scene; + if (_skipLoad) + return; + + Common::Point pt; + int listIndex = _spriteListIndexes[_header._spritesIndex]; + SpriteAsset &spriteSet = scene._spriteSlots.getSprite(listIndex); + + if (_unkIndex < 0) { + MSurface *frame = spriteSet.getFrame(0); + pt.x = frame->getBounds().left; + pt.y = frame->getBounds().top; + } else { + pt.x = _unkList[_unkIndex].x; + pt.y = _unkList[_unkIndex].y; + _unkIndex = 1 - _unkIndex; + } + + if (drawFrame(spriteSet, pt, frameNumber)) + error("proc1 failure"); +} + +bool Animation::drawFrame(SpriteAsset &spriteSet, const Common::Point &pt, int frameNumber) { + return 0; +} + void Animation::loadInterface(InterfaceSurface &interfaceSurface, MSurface &depthSurface, AAHeader &header, int flags, Common::Array *palAnimData, SceneInfo *sceneInfo) { _scene->_depthStyle = 0; @@ -323,8 +350,182 @@ void Animation::loadInterface(InterfaceSurface &interfaceSurface, MSurface &dept } } +bool Animation::hasScroll() const { + return (_header._scrollPosition.x != 0) || (_header._scrollPosition.x != 0); +} + void Animation::update() { - warning("TODO: Animation::update"); + Scene &scene = _vm->_game->_scene; + + if (_header._manualFlag) { + int spriteListIndex = _spriteListIndexes[_header._spritesIndex]; + int newIndex = -1; + + for (uint idx = _oldFrameEntry; idx < _frameEntries.size(); ++idx) { + if (_frameEntries[idx]._frameNumber > _currentFrame) + break; + if (_frameEntries[idx]._spriteSlot._spritesIndex == spriteListIndex) + newIndex = _frameEntries[idx]._spriteSlot._frameNumber; + } + + if (newIndex >= 0) + loadFrame(newIndex); + } + + // If it's not time for the next frame, then exit + if (_vm->_events->_currentTimer < _nextFrameTimer) + return; + + for (uint idx = 0; idx < scene._spriteSlots.size(); ++idx) { + if (scene._spriteSlots[idx]._seqIndex >= 0x80) + scene._spriteSlots[idx]._spriteType = ST_EXPIRED; + } + + // Validate the current frame + if (_currentFrame >= (int)_miscEntries.size()) { + // Is the animation allowed to be repeated? + if (_resetFlag) { + _currentFrame = 0; + _oldFrameEntry = 0; + } else { + _freeFlag = true; + return; + } + } + + // Handle executing any sound command for this frame + AnimMiscEntry &misc = _miscEntries[_currentFrame]; + if (misc._soundId) + _vm->_sound->command(misc._soundId); + + // Handle any screen scrolling + if (hasScroll()) { + scene._backgroundSurface.scrollX(_header._scrollPosition.x); + scene._backgroundSurface.scrollY(_header._scrollPosition.y); + scene._spriteSlots.fullRefresh(); + } + + // Handle any offset adjustment for sprites as of this frame + bool paChanged = false; + if (scene._posAdjust.x != misc._posAdjust.x) { + scene._posAdjust.x = misc._posAdjust.x; + paChanged = true; + } + if (scene._posAdjust.y != misc._posAdjust.y) { + scene._posAdjust.y = misc._posAdjust.y; + paChanged = true; + } + + int newIndex = -1; + if (paChanged) { + newIndex = scene._spriteSlots.getIndex(); + scene._spriteSlots[newIndex]._seqIndex = -1; + scene._spriteSlots[newIndex]._spriteType = ST_FULL_SCREEN_REFRESH; + } + + // Main frame animation loop - frames get animated by being placed, as necessary, into the + // main sprite slot array + while ((uint)_oldFrameEntry < _frameEntries.size()) { + if (_frameEntries[_oldFrameEntry]._frameNumber > _currentFrame) + break; + else if (_frameEntries[_oldFrameEntry]._frameNumber == _currentFrame) { + // Found the correct frame + int spriteSlotIndex = 0; + int index = 0; + + for (;;) { + if ((spriteSlotIndex == 0) && (index < (int)scene._spriteSlots.size())) { + int seqIndex = _frameEntries[_oldFrameEntry]._seqIndex - scene._spriteSlots[index]._seqIndex; + if (seqIndex == 0x80) { + if (scene._spriteSlots[index] == _frameEntries[_oldFrameEntry]._spriteSlot) { + scene._spriteSlots[index]._spriteType = ST_NONE; + spriteSlotIndex = -1; + } + } + ++index; + continue; + } + + if (spriteSlotIndex == 0) { + int slotIndex = scene._spriteSlots.getIndex(); + SpriteSlot &slot = scene._spriteSlots[slotIndex]; + slot.copy(_frameEntries[_oldFrameEntry]._spriteSlot); + slot._seqIndex = _frameEntries[_oldFrameEntry]._seqIndex + 0x80; + + SpriteAsset &spriteSet = scene._spriteSlots.getSprite( + scene._spriteSlots[slotIndex]._spritesIndex); + slot._spriteType = spriteSet.isBackground() ? ST_BACKGROUND : ST_FOREGROUND; + } + break; + } + } + + ++_oldFrameEntry; + } + + // Handle the display of any messages + for (uint idx = 0; idx < _messages.size(); ++idx) { + if (_messages[idx]._kernelMsgIndex >= 0) { + // Handle currently active message + if ((_currentFrame < _messages[idx]._startFrame) || (_currentFrame > _messages[idx]._endFrame)) { + scene._kernelMessages.remove(_messages[idx]._kernelMsgIndex); + _messages[idx]._kernelMsgIndex = -1; + --_messageCtr; + } + } else if ((_currentFrame >= _messages[idx]._startFrame) && (_currentFrame <= _messages[idx]._endFrame)) { + // Start displaying the message + AnimMessage &me = _messages[idx]; + + // 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(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, + 0, 0, INDEFINITE_TIMEOUT, me._msg); + assert(me._kernelMsgIndex >= 0); + ++_messageCtr; + } + } + + // Move to the next frame + _currentFrame++; + if (_currentFrame >= (int)_miscEntries.size()) { + // Animation is complete + if (_abortTimers != 0) { + _vm->_game->_abortTimers = _abortTimers; + _vm->_game->_abortTimersMode = _abortMode; + + if (_abortMode != ABORTMODE_1) { + // Copy the noun list + scene._action._action = _actionNouns; + } + } + } + + int frameNum = MIN(_currentFrame, (int)_miscEntries.size() - 1); + _nextFrameTimer = _vm->_events->_currentTimer + _miscEntries[frameNum]._numTicks; +} + +void Animation::setCurrentFrame(int frameNumber) { + _currentFrame = frameNumber; + _oldFrameEntry = 0; + _freeFlag = false; + + _nextScrollTimer = _nextFrameTimer = _vm->_events->_currentTimer; } } // End of namespace MADS -- cgit v1.2.3 From 3399516c5e4c2931adf76a25944cb3e46f9934ee Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 7 Mar 2014 23:07:36 -0500 Subject: MADS: Implemented remainder of scene 804 setup code and support methods --- engines/mads/animation.cpp | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index d0c7d3079b..588e4eaf36 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -140,6 +140,8 @@ Animation *Animation::init(MADSEngine *vm, Scene *scene) { Animation::Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) { _font = nullptr; _resetFlag = false; + _messageCtr = 0; + _skipLoad = false; } Animation::~Animation() { @@ -298,6 +300,32 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, f.close(); } +void Animation::startAnimation(int abortTimers) { + _messageCtr = 0; + _skipLoad = true; + + if (_header._manualFlag) { + _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); + } + + _currentFrame = 0; + _oldFrameEntry = 0; + _nextFrameTimer = _vm->_events->_currentTimer; + _abortTimers = abortTimers; + _abortTimersMode = _vm->_game->_abortTimersMode2; + _vm->_game->_scene._action._activeAction = _actionDetails; + + for (int idx = 0; idx < _header._messagesCount; ++idx) { + _messages[idx]._kernelMsgIndex = -1; + } +} + void Animation::loadFrame(int frameNumber) { Scene &scene = _vm->_game->_scene; if (_skipLoad) @@ -507,11 +535,11 @@ void Animation::update() { // Animation is complete if (_abortTimers != 0) { _vm->_game->_abortTimers = _abortTimers; - _vm->_game->_abortTimersMode = _abortMode; + _vm->_game->_abortTimersMode = _abortTimersMode; - if (_abortMode != ABORTMODE_1) { + if (_abortTimersMode != ABORTMODE_1) { // Copy the noun list - scene._action._action = _actionNouns; + scene._action._action = _actionDetails; } } } -- cgit v1.2.3 From 8d3857c0536e47a6a03497346424c111b5bebd7b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 8 Mar 2014 08:44:01 -0500 Subject: MADS: Cleanup code for accessing sprite assets --- engines/mads/animation.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 588e4eaf36..3508631690 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -332,8 +332,8 @@ void Animation::loadFrame(int frameNumber) { return; Common::Point pt; - int listIndex = _spriteListIndexes[_header._spritesIndex]; - SpriteAsset &spriteSet = scene._spriteSlots.getSprite(listIndex); + int spriteListIndex = _spriteListIndexes[_header._spritesIndex]; + SpriteAsset &spriteSet = *scene._sprites[spriteListIndex]; if (_unkIndex < 0) { MSurface *frame = spriteSet.getFrame(0); @@ -480,8 +480,8 @@ void Animation::update() { slot.copy(_frameEntries[_oldFrameEntry]._spriteSlot); slot._seqIndex = _frameEntries[_oldFrameEntry]._seqIndex + 0x80; - SpriteAsset &spriteSet = scene._spriteSlots.getSprite( - scene._spriteSlots[slotIndex]._spritesIndex); + SpriteAsset &spriteSet = *scene._sprites[ + scene._spriteSlots[slotIndex]._spritesIndex]; slot._spriteType = spriteSet.isBackground() ? ST_BACKGROUND : ST_FOREGROUND; } break; -- cgit v1.2.3 From 0f214e4c9d72d088ccf088496710b20576ec73f5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 8 Mar 2014 08:59:10 -0500 Subject: MADS: Fix for loading animation data --- engines/mads/animation.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 3508631690..90f1331d92 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -207,10 +207,11 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, for (int i = 0; i < _header._spriteSetsCount; ++i) _spriteListIndexes.push_back(-1); + int streamIndex = 1; _messages.clear(); if (_header._messagesCount > 0) { // Chunk 2: Following is a list of any messages for the animation - Common::SeekableReadStream *msgStream = madsPack.getItemStream(1); + Common::SeekableReadStream *msgStream = madsPack.getItemStream(streamIndex++); for (int i = 0; i < _header._messagesCount; ++i) { AnimMessage rec; @@ -224,7 +225,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, _frameEntries.clear(); if (_header._frameEntriesCount > 0) { // Chunk 3: animation frame info - Common::SeekableReadStream *frameStream = madsPack.getItemStream(2); + Common::SeekableReadStream *frameStream = madsPack.getItemStream(streamIndex++); for (int i = 0; i < _header._frameEntriesCount; i++) { AnimFrameEntry rec; @@ -238,7 +239,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, _miscEntries.clear(); if (_header._miscEntriesCount > 0) { // Chunk 4: Misc Data - Common::SeekableReadStream *miscStream = madsPack.getItemStream(3); + Common::SeekableReadStream *miscStream = madsPack.getItemStream(streamIndex++); for (int i = 0; i < _header._miscEntriesCount; ++i) { AnimMiscEntry rec; -- cgit v1.2.3 From 984099ae2ca9dd53b47e44e7815c560c68acbd61 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 8 Mar 2014 10:53:10 -0500 Subject: MADS: Implemented stubbed SpriteSlots methods --- engines/mads/animation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 90f1331d92..e4549d1054 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -447,7 +447,7 @@ void Animation::update() { int newIndex = -1; if (paChanged) { - newIndex = scene._spriteSlots.getIndex(); + newIndex = scene._spriteSlots.add(); scene._spriteSlots[newIndex]._seqIndex = -1; scene._spriteSlots[newIndex]._spriteType = ST_FULL_SCREEN_REFRESH; } @@ -476,7 +476,7 @@ void Animation::update() { } if (spriteSlotIndex == 0) { - int slotIndex = scene._spriteSlots.getIndex(); + int slotIndex = scene._spriteSlots.add(); SpriteSlot &slot = scene._spriteSlots[slotIndex]; slot.copy(_frameEntries[_oldFrameEntry]._spriteSlot); slot._seqIndex = _frameEntries[_oldFrameEntry]._seqIndex + 0x80; -- cgit v1.2.3 From c2587af8f29b2b79beae7fda5a9b983614840b17 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 8 Mar 2014 14:05:17 -0500 Subject: MADS: Clarified Events::_currentTimer as Scene::_frameStartTime --- engines/mads/animation.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index e4549d1054..fad5b27ea7 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -317,7 +317,7 @@ void Animation::startAnimation(int abortTimers) { _currentFrame = 0; _oldFrameEntry = 0; - _nextFrameTimer = _vm->_events->_currentTimer; + _nextFrameTimer = _vm->_game->_scene._frameStartTime; _abortTimers = abortTimers; _abortTimersMode = _vm->_game->_abortTimersMode2; _vm->_game->_scene._action._activeAction = _actionDetails; @@ -402,7 +402,7 @@ void Animation::update() { } // If it's not time for the next frame, then exit - if (_vm->_events->_currentTimer < _nextFrameTimer) + if (_vm->_game->_scene._frameStartTime < _nextFrameTimer) return; for (uint idx = 0; idx < scene._spriteSlots.size(); ++idx) { @@ -546,7 +546,7 @@ void Animation::update() { } int frameNum = MIN(_currentFrame, (int)_miscEntries.size() - 1); - _nextFrameTimer = _vm->_events->_currentTimer + _miscEntries[frameNum]._numTicks; + _nextFrameTimer = _vm->_game->_scene._frameStartTime + _miscEntries[frameNum]._numTicks; } void Animation::setCurrentFrame(int frameNumber) { @@ -554,7 +554,7 @@ void Animation::setCurrentFrame(int frameNumber) { _oldFrameEntry = 0; _freeFlag = false; - _nextScrollTimer = _nextFrameTimer = _vm->_events->_currentTimer; + _nextScrollTimer = _nextFrameTimer = _vm->_game->_scene._frameStartTime; } } // End of namespace MADS -- cgit v1.2.3 From 5536b8a933f792f45d08ab5126e826a9a20fa476 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 8 Mar 2014 15:42:07 -0500 Subject: MADS: Fixes for sprite list initialisation --- engines/mads/animation.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index fad5b27ea7..2117ae2068 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -271,6 +271,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, _spriteSets[i] = nullptr; } else { _spriteSets[i] = new SpriteAsset(_vm, _header._spriteSetNames[i], flags); + _spriteListIndexes[i] = _vm->_game->_scene._sprites.add(_spriteSets[i]); } } -- cgit v1.2.3 From 98f7ba964369b128f65755c918f4c5e6d1d16dbe Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 12 Mar 2014 08:44:57 -0400 Subject: MADS: Fix definition/loading of animation frame change data --- engines/mads/animation.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 2117ae2068..ec043a3079 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -127,8 +127,7 @@ void AnimMiscEntry::load(Common::SeekableReadStream *f) { _numTicks = f->readUint16LE(); _posAdjust.x = f->readSint16LE(); _posAdjust.y = f->readSint16LE(); - _scrollPos.x = f->readSint16LE(); - _scrollPos.y = f->readSint16LE(); + _field8 = f->readUint16LE(); } /*------------------------------------------------------------------------*/ -- cgit v1.2.3 From 408f5e79df5e8a33367fdf2a9c17b424953edace Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 12 Mar 2014 22:45:33 -0400 Subject: MADS: General cleanup and minor fixes --- engines/mads/animation.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index ec043a3079..b5ebb2c278 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -347,7 +347,7 @@ void Animation::loadFrame(int frameNumber) { } if (drawFrame(spriteSet, pt, frameNumber)) - error("proc1 failure"); + error("drawFrame failure"); } bool Animation::drawFrame(SpriteAsset &spriteSet, const Common::Point &pt, int frameNumber) { @@ -373,8 +373,7 @@ void Animation::loadInterface(InterfaceSurface &interfaceSurface, MSurface &dept if (palAnimData) palAnimData->clear(); - } - else { + } else { // Original has useless code here } } -- cgit v1.2.3 From 84fb90e7a52daffd862159d54cda4817aa930a6f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 13 Mar 2014 20:56:03 -0400 Subject: MADS: Fix GCC warnings and memory leaks --- engines/mads/animation.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index b5ebb2c278..09a9e1fc04 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -145,8 +145,6 @@ Animation::Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) { Animation::~Animation() { delete _font; - for (uint i = 0; i < _spriteSets.size(); ++i) - delete _spriteSets[i]; } void Animation::free() { -- cgit v1.2.3 From b652e2eafd3de5436b45619659b5299d945074be Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 15 Mar 2014 18:43:39 -0400 Subject: MADS: Merged the InterfaceSurface and UserInterface classes --- engines/mads/animation.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 09a9e1fc04..783611e3da 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -172,9 +172,9 @@ void Animation::free() { delete this; } -void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, - const Common::String &resName, int flags, Common::Array *palAnimData, - SceneInfo *sceneInfo) { +void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface, + const Common::String &resName, int flags, Common::Array *palAnimData, + SceneInfo *sceneInfo) { Common::String resourceName = resName; if (!resourceName.contains(".")) resourceName += ".AA"; @@ -352,7 +352,7 @@ bool Animation::drawFrame(SpriteAsset &spriteSet, const Common::Point &pt, int f return 0; } -void Animation::loadInterface(InterfaceSurface &interfaceSurface, MSurface &depthSurface, +void Animation::loadInterface(UserInterface &interfaceSurface, MSurface &depthSurface, AAHeader &header, int flags, Common::Array *palAnimData, SceneInfo *sceneInfo) { _scene->_depthStyle = 0; if (header._animMode <= 2) { @@ -363,8 +363,7 @@ void Animation::loadInterface(InterfaceSurface &interfaceSurface, MSurface &dept for (uint i = 0; i < sceneInfo->_palAnimData.size(); ++i) palAnimData->push_back(sceneInfo->_palAnimData[i]); } - } - else if (header._animMode == 4) { + } else if (header._animMode == 4) { // Load a scene interface Common::String resourceName = "*" + header._interfaceFile; interfaceSurface.load(resourceName); -- cgit v1.2.3 From 0c8a3a47e28075bd559be43bde910587af35d8ab Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 17 Mar 2014 21:53:22 -0400 Subject: MADS: Transformed ImageInterEntries to be User Interface UISlots --- engines/mads/animation.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 783611e3da..b0b69b946a 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -403,7 +403,7 @@ void Animation::update() { for (uint idx = 0; idx < scene._spriteSlots.size(); ++idx) { if (scene._spriteSlots[idx]._seqIndex >= 0x80) - scene._spriteSlots[idx]._spriteType = ST_EXPIRED; + scene._spriteSlots[idx]._SlotType = ST_EXPIRED; } // Validate the current frame @@ -445,7 +445,7 @@ void Animation::update() { if (paChanged) { newIndex = scene._spriteSlots.add(); scene._spriteSlots[newIndex]._seqIndex = -1; - scene._spriteSlots[newIndex]._spriteType = ST_FULL_SCREEN_REFRESH; + scene._spriteSlots[newIndex]._SlotType = ST_FULL_SCREEN_REFRESH; } // Main frame animation loop - frames get animated by being placed, as necessary, into the @@ -463,7 +463,7 @@ void Animation::update() { int seqIndex = _frameEntries[_oldFrameEntry]._seqIndex - scene._spriteSlots[index]._seqIndex; if (seqIndex == 0x80) { if (scene._spriteSlots[index] == _frameEntries[_oldFrameEntry]._spriteSlot) { - scene._spriteSlots[index]._spriteType = ST_NONE; + scene._spriteSlots[index]._SlotType = ST_NONE; spriteSlotIndex = -1; } } @@ -479,7 +479,7 @@ void Animation::update() { SpriteAsset &spriteSet = *scene._sprites[ scene._spriteSlots[slotIndex]._spritesIndex]; - slot._spriteType = spriteSet.isBackground() ? ST_BACKGROUND : ST_FOREGROUND; + slot._SlotType = spriteSet.isBackground() ? ST_BACKGROUND : ST_FOREGROUND; } break; } -- cgit v1.2.3 From 6c85572d76245f616ae3bf2ac1ccc713d8271fa9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 27 Mar 2014 22:38:28 -0400 Subject: MADS: Initial cleanup of action/player handling --- engines/mads/animation.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index b0b69b946a..96b9cfb90e 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -316,7 +316,7 @@ void Animation::startAnimation(int abortTimers) { _currentFrame = 0; _oldFrameEntry = 0; _nextFrameTimer = _vm->_game->_scene._frameStartTime; - _abortTimers = abortTimers; + _trigger = abortTimers; _abortTimersMode = _vm->_game->_abortTimersMode2; _vm->_game->_scene._action._activeAction = _actionDetails; @@ -530,8 +530,8 @@ void Animation::update() { _currentFrame++; if (_currentFrame >= (int)_miscEntries.size()) { // Animation is complete - if (_abortTimers != 0) { - _vm->_game->_abortTimers = _abortTimers; + if (_trigger != 0) { + _vm->_game->_trigger = _trigger; _vm->_game->_abortTimersMode = _abortTimersMode; if (_abortTimersMode != ABORTMODE_1) { -- cgit v1.2.3 From 71b1343adf6e886cfd2e1a0040a12b5025672d14 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 29 Mar 2014 11:18:07 -0400 Subject: MADS: Implemented NebularGame::step --- engines/mads/animation.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 96b9cfb90e..a8adfe3105 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -317,7 +317,7 @@ void Animation::startAnimation(int abortTimers) { _oldFrameEntry = 0; _nextFrameTimer = _vm->_game->_scene._frameStartTime; _trigger = abortTimers; - _abortTimersMode = _vm->_game->_abortTimersMode2; + _triggerMode = _vm->_game->_triggerSetupMode; _vm->_game->_scene._action._activeAction = _actionDetails; for (int idx = 0; idx < _header._messagesCount; ++idx) { @@ -532,9 +532,9 @@ void Animation::update() { // Animation is complete if (_trigger != 0) { _vm->_game->_trigger = _trigger; - _vm->_game->_abortTimersMode = _abortTimersMode; + _vm->_game->_triggerMode = _triggerMode; - if (_abortTimersMode != ABORTMODE_1) { + if (_triggerMode != KERNEL_TRIGGER_DAEMON) { // Copy the noun list scene._action._action = _actionDetails; } -- cgit v1.2.3 From 3f8ee8fafa0166204a6c0b9ec311aa9fb0aa3c39 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 2 Apr 2014 21:24:22 -0400 Subject: MADS: Cleanup of UISlots and flag types --- engines/mads/animation.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index a8adfe3105..f4fee20de7 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -403,7 +403,7 @@ void Animation::update() { for (uint idx = 0; idx < scene._spriteSlots.size(); ++idx) { if (scene._spriteSlots[idx]._seqIndex >= 0x80) - scene._spriteSlots[idx]._SlotType = ST_EXPIRED; + scene._spriteSlots[idx]._flags = IMG_ERASE; } // Validate the current frame @@ -445,7 +445,7 @@ void Animation::update() { if (paChanged) { newIndex = scene._spriteSlots.add(); scene._spriteSlots[newIndex]._seqIndex = -1; - scene._spriteSlots[newIndex]._SlotType = ST_FULL_SCREEN_REFRESH; + scene._spriteSlots[newIndex]._flags = IMG_REFRESH; } // Main frame animation loop - frames get animated by being placed, as necessary, into the @@ -463,7 +463,7 @@ void Animation::update() { int seqIndex = _frameEntries[_oldFrameEntry]._seqIndex - scene._spriteSlots[index]._seqIndex; if (seqIndex == 0x80) { if (scene._spriteSlots[index] == _frameEntries[_oldFrameEntry]._spriteSlot) { - scene._spriteSlots[index]._SlotType = ST_NONE; + scene._spriteSlots[index]._flags = IMG_STATIC; spriteSlotIndex = -1; } } @@ -479,7 +479,7 @@ void Animation::update() { SpriteAsset &spriteSet = *scene._sprites[ scene._spriteSlots[slotIndex]._spritesIndex]; - slot._SlotType = spriteSet.isBackground() ? ST_BACKGROUND : ST_FOREGROUND; + slot._flags = spriteSet.isBackground() ? IMG_DELTA : IMG_UPDATE; } break; } -- cgit v1.2.3 From b435c76b2578ad0650606ba6ad59f56eeb94ee01 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 6 Apr 2014 22:05:18 -0400 Subject: MADS: Fix loading of scene sprite set names --- engines/mads/animation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index f4fee20de7..f581bf42ce 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -51,7 +51,7 @@ void AAHeader::load(Common::SeekableReadStream *f) { buffer[FILENAME_SIZE - 1] = '\0'; _interfaceFile = Common::String(buffer); - for (int i = 0; i < 10; ++i) { + for (int i = 0; i < _spriteSetsCount; ++i) { f->read(buffer, FILENAME_SIZE); buffer[FILENAME_SIZE - 1] = '\0'; _spriteSetNames.push_back(Common::String(buffer)); -- cgit v1.2.3 From 54bcb822fbd4e5d573ae5cd00ce3b813fbc7faa6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 6 Apr 2014 22:28:14 -0400 Subject: MADS: Properly free scene-specific sprite sets when leaving scene --- engines/mads/animation.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index f581bf42ce..769bd39aef 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -144,7 +144,15 @@ Animation::Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) { } Animation::~Animation() { - delete _font; + Scene &scene = _vm->_game->_scene; + + if (_header._manualFlag) + scene._sprites.remove(_spriteListIndexes[_header._spritesIndex]); + + for (uint idx = 0; idx < _header._spriteSetsCount; ++idx) { + if (!_header._manualFlag || _header._spritesIndex != idx) + scene._sprites.remove(_spriteListIndexes[idx]); + } } void Animation::free() { -- cgit v1.2.3 From 1c50c69ba69d255e3ba9ed5a88ea0985417b9357 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 6 Apr 2014 23:53:07 -0400 Subject: MADS: Added stubbed Animation::preLoad method --- engines/mads/animation.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 769bd39aef..b557a598ed 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -307,6 +307,11 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface, f.close(); } +void Animation::preLoad(const Common::String &resName, int level) { + // No implementation in ScummVM, since access is fast enough that data + // doesn't need to be preloaded +} + void Animation::startAnimation(int abortTimers) { _messageCtr = 0; _skipLoad = true; -- cgit v1.2.3 From 7e13f488abeb6a7530d591bae880fdb185c8fef1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 7 Apr 2014 22:37:22 -0400 Subject: MADS: Implement loading logic for UI background animations --- engines/mads/animation.cpp | 72 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 53 insertions(+), 19 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index b557a598ed..40abdbe26b 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -108,15 +108,24 @@ void AnimMessage::load(Common::SeekableReadStream *f) { f->skip(2); } -void AnimFrameEntry::load(Common::SeekableReadStream *f) { - _frameNumber = f->readUint16LE(); - _seqIndex = f->readByte(); - _spriteSlot._spritesIndex = f->readByte(); - _spriteSlot._frameNumber = f->readUint16LE(); - _spriteSlot._position.x = f->readSint16LE(); - _spriteSlot._position.y = f->readSint16LE(); - _spriteSlot._depth = f->readSByte(); - _spriteSlot._scale = (int8)f->readByte(); +void AnimFrameEntry::load(Common::SeekableReadStream *f, bool uiFlag) { + if (uiFlag) { + f->skip(2); + _seqIndex = f->readByte(); + _spriteSlot._spritesIndex = f->readByte(); + _spriteSlot._frameNumber = f->readUint16LE(); + _spriteSlot._position.x = f->readSint16LE(); + _spriteSlot._position.y = f->readSint16LE(); + } else { + _frameNumber = f->readUint16LE(); + _seqIndex = f->readByte(); + _spriteSlot._spritesIndex = f->readByte(); + _spriteSlot._frameNumber = f->readUint16LE(); + _spriteSlot._position.x = f->readSint16LE(); + _spriteSlot._position.y = f->readSint16LE(); + _spriteSlot._depth = f->readSByte(); + _spriteSlot._scale = (int8)f->readByte(); + } } /*------------------------------------------------------------------------*/ @@ -132,6 +141,22 @@ void AnimMiscEntry::load(Common::SeekableReadStream *f) { /*------------------------------------------------------------------------*/ +void AnimUIEntry::load(Common::SeekableReadStream *f) { + _probability = f->readUint16LE(); + _imageCount = f->readUint16LE(); + _firstImage = f->readUint16LE(); + _lastImage = f->readUint16LE(); + _counter = f->readSint16LE(); + for (int i = 0; i < ANIM_SPAWN_COUNT; ++i) + _spawn[i] = f->readByte(); + for (int i = 0; i < ANIM_SPAWN_COUNT; ++i) + _spawnFrame[i] = f->readUint16LE(); + _sound = f->readUint16LE() & 0xFF; + _soundFrame = f->readUint16LE(); +} + +/*------------------------------------------------------------------------*/ + Animation *Animation::init(MADSEngine *vm, Scene *scene) { return new Animation(vm, scene); } @@ -149,7 +174,7 @@ Animation::~Animation() { if (_header._manualFlag) scene._sprites.remove(_spriteListIndexes[_header._spritesIndex]); - for (uint idx = 0; idx < _header._spriteSetsCount; ++idx) { + for (int idx = 0; idx < _header._spriteSetsCount; ++idx) { if (!_header._manualFlag || _header._spritesIndex != idx) scene._sprites.remove(_spriteListIndexes[idx]); } @@ -195,12 +220,12 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface, delete stream; if (_header._animMode == 4) - flags |= 0x4000; + flags |= PALFLAG_RESERVED; - if (flags & 0x100) { + if (flags & ANIMFLAG_LOAD_BACKGROUND) { loadInterface(interfaceSurface, depthSurface, _header, flags, palAnimData, sceneInfo); } - if (flags & 0x200) { + if (flags & ANIMFLAG_LOAD_BACKGROUND_ONLY) { // No data _header._messagesCount = 0; _header._frameEntriesCount = 0; @@ -234,7 +259,7 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface, for (int i = 0; i < _header._frameEntriesCount; i++) { AnimFrameEntry rec; - rec.load(frameStream); + rec.load(frameStream, flags & ANIMFLAG_LOAD_BACKGROUND); _frameEntries.push_back(rec); } @@ -242,14 +267,23 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface, } _miscEntries.clear(); + _uiEntries.clear(); if (_header._miscEntriesCount > 0) { // Chunk 4: Misc Data Common::SeekableReadStream *miscStream = madsPack.getItemStream(streamIndex++); - for (int i = 0; i < _header._miscEntriesCount; ++i) { - AnimMiscEntry rec; - rec.load(miscStream); - _miscEntries.push_back(rec); + if (flags & ANIMFLAG_LOAD_BACKGROUND) { + for (int i = 0; i < _header._miscEntriesCount; ++i) { + AnimUIEntry rec; + rec.load(miscStream); + _uiEntries.push_back(rec); + } + } else { + for (int i = 0; i < _header._miscEntriesCount; ++i) { + AnimMiscEntry rec; + rec.load(miscStream); + _miscEntries.push_back(rec); + } } delete miscStream; @@ -257,7 +291,7 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface, // If the animation specifies a font, then load it for access delete _font; - if (_header._flags & ANIM_CUSTOM_FONT) { + if (_header._flags & ANIMFLAG_CUSTOM_FONT) { Common::String fontName = "*" + _header._fontResource; _font = _vm->_font->getFont(fontName.c_str()); } else { -- cgit v1.2.3 From 2a979e59a0481f62d67b8b323c79cccaa6552d0a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 12 Apr 2014 11:00:29 -0400 Subject: MADS: Refactoring PaletteUsage to use external data arrays --- engines/mads/animation.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 40abdbe26b..0547c6b379 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -403,6 +403,7 @@ void Animation::loadInterface(UserInterface &interfaceSurface, MSurface &depthSu AAHeader &header, int flags, Common::Array *palAnimData, SceneInfo *sceneInfo) { _scene->_depthStyle = 0; if (header._animMode <= 2) { + _vm->_palette->_paletteUsage.setEmpty(); sceneInfo->load(header._roomNumber, flags, header._interfaceFile, 0, depthSurface, interfaceSurface); _scene->_depthStyle = sceneInfo->_depthStyle == 2 ? 1 : 0; if (palAnimData) { -- cgit v1.2.3 From 8b2a7525cc6af408f05e2bac9b1b16ed0b36dcda Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 12 Apr 2014 12:09:29 -0400 Subject: MADS: Fix a bunch of GCC warnings --- engines/mads/animation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 0547c6b379..ddad63ca2f 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -315,8 +315,8 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface, } if (_header._manualFlag) { - Common::String resName = "*" + _header._spriteSetNames[_header._spritesIndex]; - SpriteAsset *sprites = new SpriteAsset(_vm, resName, flags); + Common::String assetResName = "*" + _header._spriteSetNames[_header._spritesIndex]; + SpriteAsset *sprites = new SpriteAsset(_vm, assetResName, flags); _spriteSets[_header._spritesIndex] = sprites; _spriteListIndexes[_header._spritesIndex] = _scene->_sprites.add(sprites); -- cgit v1.2.3 From 9b0f0b6efec3da058157beb25bab7083328df1da Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 12 Apr 2014 16:14:57 -0400 Subject: MADS: Add missing handling code for palette _rgbList --- engines/mads/animation.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index ddad63ca2f..b79a753c28 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -322,7 +322,12 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface, _spriteListIndexes[_header._spritesIndex] = _scene->_sprites.add(sprites); } - // TODO: List var_420/var_422 population that seems to overwrite other structures? + Common::Array usageList; + for (int idx = 0; idx < _header._spriteSetsCount; ++idx) + usageList.push_back(_spriteSets[idx]->_usageIndex); + + if (usageList.size() > 0 > 0) + _vm->_palette->_paletteUsage.updateUsage(usageList, _header._messagesCount); if (_header._animMode == 4) { // Remaps the sprite list indexes for frames to the loaded sprite list indexes -- cgit v1.2.3 From 41ea3e237459091338e6057c5cc759dd65451c98 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 12 Apr 2014 17:15:05 -0400 Subject: MADS: Fix misspelling in if statement --- engines/mads/animation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index b79a753c28..d5b8e21fae 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -326,7 +326,7 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface, for (int idx = 0; idx < _header._spriteSetsCount; ++idx) usageList.push_back(_spriteSets[idx]->_usageIndex); - if (usageList.size() > 0 > 0) + if (usageList.size() > 0) _vm->_palette->_paletteUsage.updateUsage(usageList, _header._messagesCount); if (_header._animMode == 4) { -- cgit v1.2.3 From 387e7d800d89c25e6a1a89caa7a915f4575fb47b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 12 Apr 2014 17:21:04 -0400 Subject: MADS: Add missing call to new refreshHighColors method --- engines/mads/animation.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index d5b8e21fae..380770fd8f 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -365,6 +365,9 @@ void Animation::startAnimation(int abortTimers) { loadFrame(1); } + if (_vm->_game->_kernelMode == KERNEL_ACTIVE_CODE) + _vm->_palette->refreshHighColors(); + _currentFrame = 0; _oldFrameEntry = 0; _nextFrameTimer = _vm->_game->_scene._frameStartTime; -- cgit v1.2.3 From 9643b543f088449bc6728c5a884087789aa4c5c7 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 15 Apr 2014 07:45:35 +0200 Subject: MADS: Implement scene 110 --- engines/mads/animation.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 380770fd8f..06eeaf8278 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -609,4 +609,8 @@ void Animation::setCurrentFrame(int frameNumber) { _nextScrollTimer = _nextFrameTimer = _vm->_game->_scene._frameStartTime; } +void Animation::setNextFrameTimer(int frameNumber) { + _nextFrameTimer = frameNumber; +} + } // End of namespace MADS -- cgit v1.2.3 From 0b340a034330fd5124b1534544a8ef9500349411 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 15 Apr 2014 23:51:41 -0400 Subject: MADS: Fix depth issues with sitting in chair in scene 101 --- engines/mads/animation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 06eeaf8278..93cc72f613 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -590,7 +590,7 @@ void Animation::update() { _vm->_game->_trigger = _trigger; _vm->_game->_triggerMode = _triggerMode; - if (_triggerMode != KERNEL_TRIGGER_DAEMON) { + if (_triggerMode != SEQUENCE_TRIGGER_DAEMON) { // Copy the noun list scene._action._action = _actionDetails; } -- cgit v1.2.3 From cfd49436478c356c7a9baf320d3ae86dc8485361 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 16 Apr 2014 21:26:46 -0400 Subject: MADS: Fix for correctly loading animation sprite sets --- engines/mads/animation.cpp | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 93cc72f613..dd7977225f 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -51,23 +51,13 @@ void AAHeader::load(Common::SeekableReadStream *f) { buffer[FILENAME_SIZE - 1] = '\0'; _interfaceFile = Common::String(buffer); - for (int i = 0; i < _spriteSetsCount; ++i) { + for (int i = 0; i < 50; ++i) { f->read(buffer, FILENAME_SIZE); buffer[FILENAME_SIZE - 1] = '\0'; - _spriteSetNames.push_back(Common::String(buffer)); + if (i < _spriteSetsCount) + _spriteSetNames.push_back(Common::String(buffer)); } - f->skip(81); - f->read(buffer, FILENAME_SIZE); - buffer[FILENAME_SIZE - 1] = '\0'; - _lbmFilename = Common::String(buffer); - - f->skip(365); - f->read(buffer, FILENAME_SIZE); - buffer[FILENAME_SIZE - 1] = '\0'; - _spritesFilename = Common::String(buffer); - - f->skip(48); f->read(buffer, FILENAME_SIZE); buffer[FILENAME_SIZE - 1] = '\0'; _soundName = Common::String(buffer); -- cgit v1.2.3 From 73a505543829c5da58f7ac31f3a9ab87f0f8b93a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 16 Apr 2014 22:03:18 -0400 Subject: MADS: Fix unloading animations with associated messages --- engines/mads/animation.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index dd7977225f..b2c257332e 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -188,7 +188,8 @@ void Animation::free() { // Remove any kernel messages in use by the animation for (uint i = 0; i < _messages.size(); ++i) { int msgIndex = _messages[i]._kernelMsgIndex; - scene._kernelMessages.remove(msgIndex); + if (msgIndex >= 0) + scene._kernelMessages.remove(msgIndex); } _resetFlag = false; -- cgit v1.2.3 From 559efad195b2ec7e77bd9192328d9e48b2a81e29 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 19 Apr 2014 14:46:28 -0400 Subject: MADS: Moved Animation::free to be Scene::freeAnimation --- engines/mads/animation.cpp | 26 -------------------------- 1 file changed, 26 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index b2c257332e..ed274eb4a3 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -170,32 +170,6 @@ Animation::~Animation() { } } -void Animation::free() { - Scene &scene = _vm->_game->_scene; - Player &player = _vm->_game->_player; - - if (!scene._freeAnimationFlag) { - scene._spriteSlots.fullRefresh(true); - scene._sequences.scan(); - } - - // Refresh the player - if (player._visible) { - player._forceRefresh = true; - player.update(); - } - - // Remove any kernel messages in use by the animation - for (uint i = 0; i < _messages.size(); ++i) { - int msgIndex = _messages[i]._kernelMsgIndex; - if (msgIndex >= 0) - scene._kernelMessages.remove(msgIndex); - } - - _resetFlag = false; - delete this; -} - void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface, const Common::String &resName, int flags, Common::Array *palAnimData, SceneInfo *sceneInfo) { -- cgit v1.2.3 From ad6a80cae796f781e7c8a0e53ad008504c54e266 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 19 Apr 2014 20:18:39 -0400 Subject: MADS: Add support for sprite flipping in UI background animations --- engines/mads/animation.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index ed274eb4a3..fec7f74423 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -101,16 +101,19 @@ void AnimMessage::load(Common::SeekableReadStream *f) { void AnimFrameEntry::load(Common::SeekableReadStream *f, bool uiFlag) { if (uiFlag) { f->skip(2); + _frameNumber = -1; // Unused _seqIndex = f->readByte(); _spriteSlot._spritesIndex = f->readByte(); - _spriteSlot._frameNumber = f->readUint16LE(); + _spriteSlot._frameNumber = (int8)f->readByte(); + f->skip(1); _spriteSlot._position.x = f->readSint16LE(); _spriteSlot._position.y = f->readSint16LE(); } else { _frameNumber = f->readUint16LE(); _seqIndex = f->readByte(); _spriteSlot._spritesIndex = f->readByte(); - _spriteSlot._frameNumber = f->readUint16LE(); + uint frame = f->readUint16LE(); + _spriteSlot._frameNumber = (frame < 0x80) ? frame : -(frame & 0x7f); _spriteSlot._position.x = f->readSint16LE(); _spriteSlot._position.y = f->readSint16LE(); _spriteSlot._depth = f->readSByte(); -- cgit v1.2.3 From 1362414e77bfbd17d7a0224ce5fb7275c793c7c4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 19 Apr 2014 22:49:14 -0400 Subject: MADS: Implement palette animation code --- engines/mads/animation.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index fec7f74423..874ce69301 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -112,8 +112,7 @@ void AnimFrameEntry::load(Common::SeekableReadStream *f, bool uiFlag) { _frameNumber = f->readUint16LE(); _seqIndex = f->readByte(); _spriteSlot._spritesIndex = f->readByte(); - uint frame = f->readUint16LE(); - _spriteSlot._frameNumber = (frame < 0x80) ? frame : -(frame & 0x7f); + _spriteSlot._frameNumber = f->readSint16LE(); _spriteSlot._position.x = f->readSint16LE(); _spriteSlot._position.y = f->readSint16LE(); _spriteSlot._depth = f->readSByte(); @@ -174,7 +173,7 @@ Animation::~Animation() { } void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface, - const Common::String &resName, int flags, Common::Array *palAnimData, + const Common::String &resName, int flags, Common::Array *palCycles, SceneInfo *sceneInfo) { Common::String resourceName = resName; if (!resourceName.contains(".")) @@ -191,7 +190,7 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface, flags |= PALFLAG_RESERVED; if (flags & ANIMFLAG_LOAD_BACKGROUND) { - loadInterface(interfaceSurface, depthSurface, _header, flags, palAnimData, sceneInfo); + loadInterface(interfaceSurface, depthSurface, _header, flags, palCycles, sceneInfo); } if (flags & ANIMFLAG_LOAD_BACKGROUND_ONLY) { // No data @@ -376,24 +375,24 @@ bool Animation::drawFrame(SpriteAsset &spriteSet, const Common::Point &pt, int f } void Animation::loadInterface(UserInterface &interfaceSurface, MSurface &depthSurface, - AAHeader &header, int flags, Common::Array *palAnimData, SceneInfo *sceneInfo) { + AAHeader &header, int flags, Common::Array *palCycles, SceneInfo *sceneInfo) { _scene->_depthStyle = 0; if (header._animMode <= 2) { _vm->_palette->_paletteUsage.setEmpty(); sceneInfo->load(header._roomNumber, flags, header._interfaceFile, 0, depthSurface, interfaceSurface); _scene->_depthStyle = sceneInfo->_depthStyle == 2 ? 1 : 0; - if (palAnimData) { - palAnimData->clear(); - for (uint i = 0; i < sceneInfo->_palAnimData.size(); ++i) - palAnimData->push_back(sceneInfo->_palAnimData[i]); + if (palCycles) { + palCycles->clear(); + for (uint i = 0; i < sceneInfo->_paletteCycles.size(); ++i) + palCycles->push_back(sceneInfo->_paletteCycles[i]); } } else if (header._animMode == 4) { // Load a scene interface Common::String resourceName = "*" + header._interfaceFile; interfaceSurface.load(resourceName); - if (palAnimData) - palAnimData->clear(); + if (palCycles) + palCycles->clear(); } else { // Original has useless code here } -- cgit v1.2.3 From 88cf2c7caab3ce74460a980640b9fe832f4fba5f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 1 May 2014 09:17:10 -0400 Subject: MADS: Fix actions being triggered at the end of animation sequences --- engines/mads/animation.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 874ce69301..bfcbe16e28 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -318,7 +318,7 @@ void Animation::preLoad(const Common::String &resName, int level) { // doesn't need to be preloaded } -void Animation::startAnimation(int abortTimers) { +void Animation::startAnimation(int endTrigger) { _messageCtr = 0; _skipLoad = true; @@ -338,9 +338,9 @@ void Animation::startAnimation(int abortTimers) { _currentFrame = 0; _oldFrameEntry = 0; _nextFrameTimer = _vm->_game->_scene._frameStartTime; - _trigger = abortTimers; + _trigger = endTrigger; _triggerMode = _vm->_game->_triggerSetupMode; - _vm->_game->_scene._action._activeAction = _actionDetails; + _actionDetails = _vm->_game->_scene._action._activeAction; for (int idx = 0; idx < _header._messagesCount; ++idx) { _messages[idx]._kernelMsgIndex = -1; @@ -559,7 +559,7 @@ void Animation::update() { if (_triggerMode != SEQUENCE_TRIGGER_DAEMON) { // Copy the noun list - scene._action._action = _actionDetails; + scene._action._activeAction = _actionDetails; } } } -- cgit v1.2.3 From 8c58a046dbae7c07b06b21c4b42d3b5206841569 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 1 May 2014 20:54:17 -0400 Subject: MADS: Fix palette corruption when playing animations --- engines/mads/animation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index bfcbe16e28..32f432001e 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -333,7 +333,7 @@ void Animation::startAnimation(int endTrigger) { } if (_vm->_game->_kernelMode == KERNEL_ACTIVE_CODE) - _vm->_palette->refreshHighColors(); + _vm->_palette->refreshSceneColors(); _currentFrame = 0; _oldFrameEntry = 0; -- cgit v1.2.3 From b7dd01fdefd910c3c0f6291145ceab4060ae1a70 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 8 May 2014 11:43:23 +0300 Subject: MADS: Remove trailing whitespace --- engines/mads/animation.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 32f432001e..089e21d08e 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -26,7 +26,7 @@ #define FILENAME_SIZE 13 namespace MADS { - + void AAHeader::load(Common::SeekableReadStream *f) { _spriteSetsCount = f->readUint16LE(); _miscEntriesCount = f->readUint16LE(); @@ -232,7 +232,7 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface, delete frameStream; } - + _miscEntries.clear(); _uiEntries.clear(); if (_header._miscEntriesCount > 0) { @@ -255,7 +255,7 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface, delete miscStream; } - + // If the animation specifies a font, then load it for access delete _font; if (_header._flags & ANIMFLAG_CUSTOM_FONT) { @@ -264,7 +264,7 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface, } else { _font = nullptr; } - + // Load all the sprite sets for the animation for (uint i = 0; i < _spriteSets.size(); ++i) delete _spriteSets[i]; @@ -398,7 +398,7 @@ void Animation::loadInterface(UserInterface &interfaceSurface, MSurface &depthSu } } -bool Animation::hasScroll() const { +bool Animation::hasScroll() const { return (_header._scrollPosition.x != 0) || (_header._scrollPosition.x != 0); } @@ -452,7 +452,7 @@ void Animation::update() { scene._backgroundSurface.scrollY(_header._scrollPosition.y); scene._spriteSlots.fullRefresh(); } - + // Handle any offset adjustment for sprites as of this frame bool paChanged = false; if (scene._posAdjust.x != misc._posAdjust.x) { @@ -542,7 +542,7 @@ void Animation::update() { _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, colIndex * 0x101 + 0x100, 0, 0, INDEFINITE_TIMEOUT, me._msg); assert(me._kernelMsgIndex >= 0); ++_messageCtr; -- cgit v1.2.3 From 20c26931269871f599897d01cb93502bd58b1412 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 19 May 2014 21:40:12 +0200 Subject: MADS: Fix scrolling check --- engines/mads/animation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 089e21d08e..3e10fe9667 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -399,7 +399,7 @@ void Animation::loadInterface(UserInterface &interfaceSurface, MSurface &depthSu } bool Animation::hasScroll() const { - return (_header._scrollPosition.x != 0) || (_header._scrollPosition.x != 0); + return (_header._scrollPosition.x != 0) || (_header._scrollPosition.y != 0); } void Animation::update() { -- cgit v1.2.3 From 83f82104d0a49ba9eff521426b58831ac3b21a86 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 19 May 2014 21:46:15 +0200 Subject: MADS: Reduce the scope of another variable in Animation --- engines/mads/animation.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 3e10fe9667..f006d1fe61 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -464,9 +464,8 @@ void Animation::update() { paChanged = true; } - int newIndex = -1; if (paChanged) { - newIndex = scene._spriteSlots.add(); + int newIndex = scene._spriteSlots.add(); scene._spriteSlots[newIndex]._seqIndex = -1; scene._spriteSlots[newIndex]._flags = IMG_REFRESH; } -- cgit v1.2.3 From df23dff5177ece670f2fd8222337faa80baf12bd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 20 May 2014 21:11:53 -0400 Subject: MADS: Change the animation _animMode to an enum'ed _bgType --- engines/mads/animation.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index f006d1fe61..f55e485c20 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -36,7 +36,7 @@ void AAHeader::load(Common::SeekableReadStream *f) { _flags = f->readByte(); f->skip(2); - _animMode = f->readUint16LE(); + _bgType = (AnimBgType)f->readUint16LE(); _roomNumber = f->readUint16LE(); f->skip(2); _manualFlag = f->readUint16LE() != 0; @@ -186,7 +186,7 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface, _header.load(stream); delete stream; - if (_header._animMode == 4) + if (_header._bgType == ANIMBG_INTERFACE) flags |= PALFLAG_RESERVED; if (flags & ANIMFLAG_LOAD_BACKGROUND) { @@ -296,7 +296,7 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface, if (usageList.size() > 0) _vm->_palette->_paletteUsage.updateUsage(usageList, _header._messagesCount); - if (_header._animMode == 4) { + if (_header._bgType == ANIMBG_INTERFACE) { // Remaps the sprite list indexes for frames to the loaded sprite list indexes for (uint i = 0; i < _frameEntries.size(); ++i) { int spriteListIndex = _frameEntries[i]._spriteSlot._spritesIndex; @@ -377,7 +377,7 @@ bool Animation::drawFrame(SpriteAsset &spriteSet, const Common::Point &pt, int f void Animation::loadInterface(UserInterface &interfaceSurface, MSurface &depthSurface, AAHeader &header, int flags, Common::Array *palCycles, SceneInfo *sceneInfo) { _scene->_depthStyle = 0; - if (header._animMode <= 2) { + if (header._bgType <= ANIMBG_FULL_SIZE) { _vm->_palette->_paletteUsage.setEmpty(); sceneInfo->load(header._roomNumber, flags, header._interfaceFile, 0, depthSurface, interfaceSurface); _scene->_depthStyle = sceneInfo->_depthStyle == 2 ? 1 : 0; @@ -386,7 +386,7 @@ void Animation::loadInterface(UserInterface &interfaceSurface, MSurface &depthSu for (uint i = 0; i < sceneInfo->_paletteCycles.size(); ++i) palCycles->push_back(sceneInfo->_paletteCycles[i]); } - } else if (header._animMode == 4) { + } else if (header._bgType == ANIMBG_INTERFACE) { // Load a scene interface Common::String resourceName = "*" + header._interfaceFile; interfaceSurface.load(resourceName); -- cgit v1.2.3 From 17012de54b900400548d598fe051343924838565 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 20 May 2014 22:34:26 -0400 Subject: MADS: Remove redundant frame entry remap block in animation loading --- engines/mads/animation.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index f55e485c20..25fa4a8e06 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -296,18 +296,10 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface, if (usageList.size() > 0) _vm->_palette->_paletteUsage.updateUsage(usageList, _header._messagesCount); - if (_header._bgType == ANIMBG_INTERFACE) { - // Remaps the sprite list indexes for frames to the loaded sprite list indexes - for (uint i = 0; i < _frameEntries.size(); ++i) { - int spriteListIndex = _frameEntries[i]._spriteSlot._spritesIndex; - _frameEntries[i]._spriteSlot._spritesIndex = _spriteListIndexes[spriteListIndex]; - } - } else { - // Remaps the sprite list indexes for frames to the loaded sprite list indexes - for (uint i = 0; i < _frameEntries.size(); ++i) { - int spriteListIndex = _frameEntries[i]._spriteSlot._spritesIndex; - _frameEntries[i]._spriteSlot._spritesIndex = _spriteListIndexes[spriteListIndex]; - } + // Remaps the sprite list indexes for frames to the loaded sprite list indexes + for (uint i = 0; i < _frameEntries.size(); ++i) { + int spriteListIndex = _frameEntries[i]._spriteSlot._spritesIndex; + _frameEntries[i]._spriteSlot._spritesIndex = _spriteListIndexes[spriteListIndex]; } f.close(); -- cgit v1.2.3 From ea19581ae30bed434da8c9426c7b6defd702fc88 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 25 May 2014 13:23:05 -0400 Subject: MADS: Standardised on passing depth surfaces as DepthSurface --- engines/mads/animation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 25fa4a8e06..ac8c9969b7 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -172,7 +172,7 @@ Animation::~Animation() { } } -void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface, +void Animation::load(UserInterface &interfaceSurface, DepthSurface &depthSurface, const Common::String &resName, int flags, Common::Array *palCycles, SceneInfo *sceneInfo) { Common::String resourceName = resName; @@ -366,7 +366,7 @@ bool Animation::drawFrame(SpriteAsset &spriteSet, const Common::Point &pt, int f return 0; } -void Animation::loadInterface(UserInterface &interfaceSurface, MSurface &depthSurface, +void Animation::loadInterface(UserInterface &interfaceSurface, DepthSurface &depthSurface, AAHeader &header, int flags, Common::Array *palCycles, SceneInfo *sceneInfo) { _scene->_depthStyle = 0; if (header._bgType <= ANIMBG_FULL_SIZE) { -- cgit v1.2.3 From 53332f8ab879b150883544fb8ea3987bdc190cdf Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 26 May 2014 23:16:24 -0400 Subject: MADS: Fix occassional character gliding in cutscenes --- engines/mads/animation.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index ac8c9969b7..0f98cb52e6 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -110,9 +110,15 @@ void AnimFrameEntry::load(Common::SeekableReadStream *f, bool uiFlag) { _spriteSlot._position.y = f->readSint16LE(); } else { _frameNumber = f->readUint16LE(); + if (_frameNumber & 0x8000) + _frameNumber = -(_frameNumber & 0x7fff); + _seqIndex = f->readByte(); _spriteSlot._spritesIndex = f->readByte(); - _spriteSlot._frameNumber = f->readSint16LE(); + _spriteSlot._frameNumber = f->readUint16LE(); + if (_spriteSlot._frameNumber & 0x8000) + _spriteSlot._frameNumber = -(_spriteSlot._frameNumber & 0x7fff); + _spriteSlot._position.x = f->readSint16LE(); _spriteSlot._position.y = f->readSint16LE(); _spriteSlot._depth = f->readSByte(); -- cgit v1.2.3 From 25c153ff29baca89f5b594b70a8ff949d8edb89d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 28 May 2014 00:51:48 +0200 Subject: MADS: Initialize variables in Animation --- engines/mads/animation.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 0f98cb52e6..6af8a9ae5f 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -164,6 +164,17 @@ Animation::Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) { _resetFlag = false; _messageCtr = 0; _skipLoad = false; + _freeFlag = false; + _unkIndex = -1; + _nextFrameTimer = 0; + _nextScrollTimer = 0; + _trigger = 0; + _triggerMode = SEQUENCE_TRIGGER_PREPARE; + _actionDetails._verbId = VERB_NONE; + _actionDetails._objectNameId = -1; + _actionDetails._indirectObjectId = -1; + _currentFrame = 0; + _oldFrameEntry = 0; } Animation::~Animation() { -- cgit v1.2.3 From c551115b4b31e653cc046b6ea91fd306e6b8dc5e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 4 Jun 2014 09:30:10 -0400 Subject: MADS: Fix memory corruption when dealing with monster in scene 703 --- engines/mads/animation.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'engines/mads/animation.cpp') diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 6af8a9ae5f..512a3979f9 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -310,8 +310,10 @@ void Animation::load(UserInterface &interfaceSurface, DepthSurface &depthSurface for (int idx = 0; idx < _header._spriteSetsCount; ++idx) usageList.push_back(_spriteSets[idx]->_usageIndex); - if (usageList.size() > 0) - _vm->_palette->_paletteUsage.updateUsage(usageList, _header._messagesCount); + if (usageList.size() > 0) { + int spritesUsageIndex = _spriteSets[0]->_usageIndex; + _vm->_palette->_paletteUsage.updateUsage(usageList, spritesUsageIndex); + } // Remaps the sprite list indexes for frames to the loaded sprite list indexes for (uint i = 0; i < _frameEntries.size(); ++i) { -- cgit v1.2.3