From a77ed90618664e50705b3e59dd2111faec2f5f39 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 6 Mar 2014 22:31:41 -0500 Subject: MADS: Implementing support methods needed for scene 804 initialisation --- engines/mads/nebular/globals_nebular.cpp | 5 ++-- engines/mads/nebular/globals_nebular.h | 2 ++ engines/mads/nebular/nebular_scenes.cpp | 41 +++++++++++++++++++++++++++++++- engines/mads/nebular/nebular_scenes.h | 16 +++++++++++++ engines/mads/nebular/nebular_scenes8.cpp | 32 +++++++++++++++++++++++++ 5 files changed, 92 insertions(+), 4 deletions(-) (limited to 'engines/mads/nebular') diff --git a/engines/mads/nebular/globals_nebular.cpp b/engines/mads/nebular/globals_nebular.cpp index 20789cd154..37ebf5f8d6 100644 --- a/engines/mads/nebular/globals_nebular.cpp +++ b/engines/mads/nebular/globals_nebular.cpp @@ -29,10 +29,9 @@ namespace MADS { namespace Nebular { Globals::Globals() { - // Initialise global flags + // Initialise lists _flags.resize(210); - for (int i = 0; i < 210; ++i) - _flags[i] = 0; + _spriteIndexes.resize(30); // Initialise game flags _chairHotspotIndex = 0; diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h index 0d8da78e42..daa384f88f 100644 --- a/engines/mads/nebular/globals_nebular.h +++ b/engines/mads/nebular/globals_nebular.h @@ -35,6 +35,8 @@ class Globals { private: Common::Array _flags; public: + Common::Array _spriteIndexes; + int _chairHotspotIndex; int _v1; int _v2; diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp index f82e102bfa..d14120a5b7 100644 --- a/engines/mads/nebular/nebular_scenes.cpp +++ b/engines/mads/nebular/nebular_scenes.cpp @@ -23,7 +23,10 @@ #include "common/scummsys.h" #include "common/config-manager.h" #include "mads/mads.h" +#include "mads/compression.h" +#include "mads/resources.h" #include "mads/scene.h" +#include "mads/nebular/game_nebular.h" #include "mads/nebular/nebular_scenes.h" #include "mads/nebular/nebular_scenes8.h" @@ -46,7 +49,43 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) { return new Scene804(vm); } -NebularScene::NebularScene(MADSEngine *vm) : SceneLogic(vm) { +/*------------------------------------------------------------------------*/ + +NebularScene::NebularScene(MADSEngine *vm) : SceneLogic(vm), + _globals(static_cast(vm->_game)->_globals) { +} + +Common::String NebularScene::formAnimName(char sepChar, int suffixNum) { + return Resources::formatName(_scene->_currentSceneId, sepChar, suffixNum, + EXT_NONE, ""); +} + +/*------------------------------------------------------------------------*/ + +void SceneInfoNebular::loadCodes(MSurface &depthSurface) { + File f(Resources::formatName(RESPREFIX_RM, _sceneId, ".DAT")); + MadsPack codesPack(&f); + Common::SeekableReadStream *stream = codesPack.getItemStream(0); + + byte *destP = depthSurface.getData(); + byte *endP = depthSurface.getBasePtr(0, depthSurface.h); + + byte runLength = stream->readByte(); + while (destP < endP && runLength > 0) { + byte runValue = stream->readByte(); + + // Write out the run length + Common::fill(destP, destP + runLength, runValue); + destP += runLength; + + // Get the next run length + runLength = stream->readByte(); + } + + if (destP < endP) + Common::fill(destP, endP, 0); + delete stream; + f.close(); } } // End of namespace Nebular diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h index 9d617bb543..92b5626bf0 100644 --- a/engines/mads/nebular/nebular_scenes.h +++ b/engines/mads/nebular/nebular_scenes.h @@ -95,6 +95,11 @@ public: class NebularScene : public SceneLogic { protected: Globals &_globals; + + /** + * Forms an animation resoucre name + */ + Common::String formAnimName(char sepChar, int suffixNum); public: /** * Constructor @@ -102,6 +107,17 @@ public: NebularScene(MADSEngine *vm); }; +class SceneInfoNebular : public SceneInfo { + friend class SceneInfo; +protected: + virtual void loadCodes(MSurface &depthSurface); + + /** + * Constructor + */ + SceneInfoNebular(MADSEngine *vm) : SceneInfo(vm) {} +}; + } // End of namespace Nebular } // End of namespace MADS diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp index d08e64506e..773b0e6d7a 100644 --- a/engines/mads/nebular/nebular_scenes8.cpp +++ b/engines/mads/nebular/nebular_scenes8.cpp @@ -75,6 +75,38 @@ void Scene8xx::enter1() { /*------------------------------------------------------------------------*/ void Scene804::setup() { + _globals._chairHotspotIndex = 0; + _globals._v1 = _globals._v2 = 0; + _globals._v3 = _globals._v4 = 0; + _globals._v5 = -1; + _globals._v6 = _globals._v7 = 0; + _globals._v8 = 0; + if (_globals[5]) { + // Copy protection failed + _globals[165] = 0xFFFF; + _globals[164] = 0; + } + + _globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 0)); + _globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 1)); + _globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('x', 2)); + _globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('x', 3)); + _globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('x', 4)); + _globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('f', 1)); + + _vm->_game->loadQuoteSet(791, 0); + + if (_globals[165]) { + if (_globals[164]) { + _globals._spriteIndexes[19] = _scene->_sequences.startCycle( + _globals._spriteIndexes[4], 0, 1); + // TODO + } else { + + } + } else { + // TODO + } } void Scene804::enter() { -- cgit v1.2.3