diff options
author | Paul Gilbert | 2010-02-21 01:18:03 +0000 |
---|---|---|
committer | Paul Gilbert | 2010-02-21 01:18:03 +0000 |
commit | 6969b5ebe6f428afaf9828d395d57e6c0edb6240 (patch) | |
tree | e9d34dc50621ca6f26e55ab51eb1b62c5a4f2c91 /engines | |
parent | 43ca6071eaa559d04988910491b3013664e9f396 (diff) | |
download | scummvm-rg350-6969b5ebe6f428afaf9828d395d57e6c0edb6240.tar.gz scummvm-rg350-6969b5ebe6f428afaf9828d395d57e6c0edb6240.tar.bz2 scummvm-rg350-6969b5ebe6f428afaf9828d395d57e6c0edb6240.zip |
Implemented some of the sprite animations loading logic for the first scene (no display yet)
svn-id: r48099
Diffstat (limited to 'engines')
-rw-r--r-- | engines/m4/mads_logic.cpp | 21 | ||||
-rw-r--r-- | engines/m4/mads_logic.h | 4 | ||||
-rw-r--r-- | engines/m4/resource.cpp | 2 | ||||
-rw-r--r-- | engines/m4/scene.cpp | 34 | ||||
-rw-r--r-- | engines/m4/scene.h | 1 |
5 files changed, 51 insertions, 11 deletions
diff --git a/engines/m4/mads_logic.cpp b/engines/m4/mads_logic.cpp index 693dd7d03f..5f6ccdb794 100644 --- a/engines/m4/mads_logic.cpp +++ b/engines/m4/mads_logic.cpp @@ -31,7 +31,7 @@ namespace M4 { /*--------------------------------------------------------------------------*/ -const char *MadsSceneLogic::formAnimName(char sepChar, int suffixNum) { +const char *MadsSceneLogic::formAnimName(char sepChar, int16 suffixNum) { return MADSResourceManager::getResourceName(sepChar, _sceneNumber, EXTTYPE_NONE, NULL, suffixNum); } @@ -71,6 +71,15 @@ void MadsSceneLogic::getAnimName() { /*--------------------------------------------------------------------------*/ +uint16 MadsSceneLogic::loadSpriteSet(uint16 suffixNum, uint16 sepChar) { + assert(sepChar < 256); + const char *resName = formAnimName((char)sepChar, (int16)suffixNum); + return _madsVm->scene()->loadSceneSpriteSet(resName); +} + + +/*--------------------------------------------------------------------------*/ + /** * FIXME: * Currently I'm only working at providing manual implementation of the first Rex Nebular scene. @@ -96,7 +105,15 @@ warning("anim - %s\n", animName); } void MadsSceneLogic::enterScene() { - + for (int i = 1; i <= 7; ++i) + _spriteIndexes[i - 1] = loadSpriteSet(i, 'x'); + _spriteIndexes[7] = loadSpriteSet(0xFFFF, 'm'); + _spriteIndexes[8] = loadSpriteSet(1, 'b'); + _spriteIndexes[9] = loadSpriteSet(2, 'b'); + _spriteIndexes[10] = loadSpriteSet(0, 'a'); + _spriteIndexes[11] = loadSpriteSet(1, 'a'); + _spriteIndexes[12] = loadSpriteSet(8, 'x'); + _spriteIndexes[13] = loadSpriteSet(0, 'x'); } void MadsSceneLogic::doAction() { diff --git a/engines/m4/mads_logic.h b/engines/m4/mads_logic.h index 7c8b1b8054..2514f4e3f4 100644 --- a/engines/m4/mads_logic.h +++ b/engines/m4/mads_logic.h @@ -34,11 +34,13 @@ namespace M4 { class MadsSceneLogic { private: // Library interface methods + uint16 loadSpriteSet(uint16 suffixNum, uint16 sepChar); private: int _sceneNumber; + uint16 _spriteIndexes[50]; // Support functions - const char *formAnimName(char sepChar, int suffixNum); + const char *formAnimName(char sepChar, int16 suffixNum); void getSceneSpriteSet(); void getAnimName(); public: diff --git a/engines/m4/resource.cpp b/engines/m4/resource.cpp index 747077ac74..a1c5290afa 100644 --- a/engines/m4/resource.cpp +++ b/engines/m4/resource.cpp @@ -334,7 +334,7 @@ const char *MADSResourceManager::getResourceName(char asciiCh, int prefix, Exten strcat(resourceName, asciiStr); // Add in the index specified - if (index > 0) + if (index >= 0) sprintf(resourceName + strlen(resourceName), "%d", index); // Add in any suffix diff --git a/engines/m4/scene.cpp b/engines/m4/scene.cpp index a5982219a0..e70b4d4bd8 100644 --- a/engines/m4/scene.cpp +++ b/engines/m4/scene.cpp @@ -608,10 +608,18 @@ void MadsScene::loadScene(int sceneNumber) { // Handle common scene setting Scene::loadScene(sceneNumber); + // Signal the script engine what scene is to be active _sceneLogic.selectScene(sceneNumber); - _vm->globals()->addVisitedScene(sceneNumber); _sceneLogic.setupScene(); + // Add the scene if necessary to the list of scenes that have been visited + _vm->globals()->addVisitedScene(sceneNumber); + + + // Do any scene specific setup + _sceneLogic.enterScene(); + + /* Existing code that eventually needs to be replaced with the proper MADS code */ // Set system palette entries _vm->_palette->blockRange(0, 7); RGB8 sysColors[3] = { {0x1f<<2, 0x2d<<2, 0x31<<2, 0}, {0x24<<2, 0x37<<2, 0x3a<<2, 0}, @@ -787,6 +795,23 @@ void MadsScene::update() { _sceneSprites[0]->getFrame(1)->copyTo(this, 120, 90, 0); } +int MadsScene::loadSceneSpriteSet(const char *setName) { + char resName[100]; + strcpy(resName, setName); + + // Append a '.SS' if it doesn't alreayd have an extension + if (!strchr(resName, '.')) + strcat(resName, ".SS"); + + Common::SeekableReadStream *data = _vm->res()->get(resName); + SpriteAsset *spriteSet = new SpriteAsset(_vm, data, data->size(), resName); + spriteSet->translate(_vm->_palette); + _vm->res()->toss(resName); + + _sceneSprites.push_back(spriteSet); + return _sceneSprites.size() - 1; +} + void MadsScene::loadPlayerSprites(const char *prefix) { const char suffixList[8] = { '8', '9', '6', '3', '2', '7', '4', '1' }; char setName[80]; @@ -800,12 +825,7 @@ void MadsScene::loadPlayerSprites(const char *prefix) { *digitP = suffixList[idx]; if (_vm->res()->resourceExists(setName)) { - Common::SeekableReadStream *data = _vm->res()->get(setName); - SpriteAsset *playerSprites = new SpriteAsset(_vm, data, data->size(), setName); - playerSprites->translate(_vm->_palette); - _vm->res()->toss(setName); - - _sceneSprites.push_back(playerSprites); + loadSceneSpriteSet(setName); return; } } diff --git a/engines/m4/scene.h b/engines/m4/scene.h index b0f97ff1a5..a0a07bce6a 100644 --- a/engines/m4/scene.h +++ b/engines/m4/scene.h @@ -189,6 +189,7 @@ public: virtual void setStatusText(const char *text); virtual void update(); + int loadSceneSpriteSet(const char *setName); void loadPlayerSprites(const char *prefix); MadsInterfaceView *getInterface() { return (MadsInterfaceView *)_interfaceSurface; }; |