aboutsummaryrefslogtreecommitdiff
path: root/engines/neverhood/module1700.cpp
diff options
context:
space:
mode:
authorjohndoe1232011-07-26 08:38:19 +0000
committerWillem Jan Palenstijn2013-05-08 20:39:34 +0200
commitbfd71cff6e73c0be6b2d66f7f71921094f42ca09 (patch)
tree01acbaf984c307fb7e7978706ac78d023e758ce7 /engines/neverhood/module1700.cpp
parent04d2b9a4028d1f6ac7c5c5e4a6cc95f8532e9cdf (diff)
downloadscummvm-rg350-bfd71cff6e73c0be6b2d66f7f71921094f42ca09.tar.gz
scummvm-rg350-bfd71cff6e73c0be6b2d66f7f71921094f42ca09.tar.bz2
scummvm-rg350-bfd71cff6e73c0be6b2d66f7f71921094f42ca09.zip
NEVERHOOD: New modules Module1200, Module1400, Module1700 and Module1800
- Implement CollisionMan::removeSprite
Diffstat (limited to 'engines/neverhood/module1700.cpp')
-rw-r--r--engines/neverhood/module1700.cpp359
1 files changed, 359 insertions, 0 deletions
diff --git a/engines/neverhood/module1700.cpp b/engines/neverhood/module1700.cpp
new file mode 100644
index 0000000000..3289173dfb
--- /dev/null
+++ b/engines/neverhood/module1700.cpp
@@ -0,0 +1,359 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "neverhood/module1700.h"
+#include "neverhood/navigationscene.h"
+
+namespace Neverhood {
+
+Module1700::Module1700(NeverhoodEngine *vm, Module *parentModule, int which)
+ : Module(vm, parentModule), _soundResource(vm) {
+
+ debug("Create Module1700(%d)", which);
+
+ // TODO Music18hList_add(0x04212331);
+ // TODO Sound1ChList_addSoundResources(0x04212331, dword_4AE930, true);
+ // TODO Sound1ChList_setSoundValuesMulti(dword_4AE930, 1, 50, 600, 5, 150);
+ // TODO Sound1ChList_sub_407C70(0x04212331, 0x41861371, 0x43A2507F, 0);
+
+ if (which < 0) {
+ switch (_vm->gameState().sceneNum) {
+ case 0:
+ createScene1701(-1);
+ break;
+ case 1:
+ createScene1702(-1);
+ break;
+ case 2:
+ createScene1703(-1);
+ break;
+ case 3:
+ createScene1704(-1);
+ break;
+ default:
+ createScene1705(-1);
+ }
+ } else if (which == 0) {
+ createScene1701(-1);
+ } else if (which == 1) {
+ createScene1705(1);
+ } else {
+ createScene1705(3);
+ }
+
+}
+
+Module1700::~Module1700() {
+ // TODO Sound1ChList_sub_407A50(0x04212331);
+}
+
+void Module1700::createScene1701(int which) {
+ SmackerScene *smackerScene;
+ _vm->gameState().sceneNum = 0;
+ // TODO Sound1ChList_setSoundValuesMulti(dword_4AE930, 0, 0, 0, 0, 0);
+ smackerScene = new SmackerScene(_vm, this, true, true, false);
+ smackerScene->setFileHash(0x3028A005);
+ smackerScene->nextVideo();
+ _childObject = smackerScene;
+ SetUpdateHandler(&Module1700::updateScene1701);
+}
+
+void Module1700::createScene1702(int which) {
+ _vm->gameState().sceneNum = 1;
+ _childObject = new NavigationScene(_vm, this, 0x004AE8B8, which, NULL);
+ SetUpdateHandler(&Module1700::updateScene1702);
+}
+
+void Module1700::createScene1703(int which) {
+ _vm->gameState().sceneNum = 2;
+ _childObject = new NavigationScene(_vm, this, 0x004AE8E8, which, NULL);
+ SetUpdateHandler(&Module1700::updateScene1703);
+}
+
+void Module1700::createScene1704(int which) {
+ SmackerScene *smackerScene;
+ _vm->gameState().sceneNum = 3;
+ // TODO Sound1ChList_setSoundValuesMulti(dword_4AE930, 0, 0, 0, 0, 0);
+ smackerScene = new SmackerScene(_vm, this, true, true, false);
+ smackerScene->setFileHash(0x01190041);
+ smackerScene->nextVideo();
+ _childObject = smackerScene;
+ SetUpdateHandler(&Module1700::updateScene1701);
+}
+
+void Module1700::createScene1705(int which) {
+ _vm->gameState().sceneNum = 4;
+ // TODO Sound1ChList_setSoundValuesMulti(dword_4AE930, 0, 0, 0, 0, 0);
+ // TODO Music18hList_play(0x31114225, 0, 2, 1);
+ _childObject = new Scene1705(_vm, this, which);
+ SetUpdateHandler(&Module1700::updateScene1705);
+}
+
+void Module1700::updateScene1701() {
+ _childObject->handleUpdate();
+ if (_done) {
+ _done = false;
+ delete _childObject;
+ _childObject = NULL;
+ if (_vm->gameState().sceneNum == 3) {
+ createScene1705(0);
+ _childObject->handleUpdate();
+ } else {
+ // TODO Sound1ChList_setSoundValuesMulti(dword_4AE930, 1, 0, 0, 0);
+ createScene1702(0);
+ _childObject->handleUpdate();
+ }
+ }
+}
+
+void Module1700::updateScene1702() {
+ _childObject->handleUpdate();
+ if (_done) {
+ _done = false;
+ delete _childObject;
+ _childObject = NULL;
+ if (_field20 == 0) {
+ createScene1703(0);
+ _childObject->handleUpdate();
+ } else if (_field20 == 1) {
+ createScene1702(1);
+ _childObject->handleUpdate();
+ }
+ }
+}
+
+void Module1700::updateScene1703() {
+ _childObject->handleUpdate();
+ if (_done) {
+ _done = false;
+ delete _childObject;
+ _childObject = NULL;
+ if (_field20 == 0) {
+ createScene1704(-1);
+ _childObject->handleUpdate();
+ } else if (_field20 == 1) {
+ createScene1702(1);
+ _childObject->handleUpdate();
+ } else if (_field20 == 2) {
+ if (!_soundResource.isPlaying()) {
+ // TODO _soundResource.setVolume(60);
+ _soundResource.play(0x58B45E58);
+ }
+ createScene1703(2);
+ _childObject->handleUpdate();
+ }
+ }
+}
+
+void Module1700::updateScene1705() {
+ _childObject->handleUpdate();
+ if (_done) {
+ _done = false;
+ delete _childObject;
+ _childObject = NULL;
+ _parentModule->sendMessage(0x1009, 1, this);
+ }
+}
+
+// Scene1705
+
+static const uint32 kScene1705FileHashes[] = {
+ 0x910EA801,
+ 0x920EA801,
+ 0x940EA801,
+ 0x980EA801,
+ 0x800EA801,
+ 0xB00EA801,
+ 0xD00EA801,
+ 0x100EA801,
+ 0x900EA800,
+ 0xD10EA801,
+ 0x110EA801,
+ 0x910EA800
+};
+
+Class602::Class602(NeverhoodEngine *vm, uint32 fileHash, int index)
+ : StaticSprite(vm, fileHash, 100) {
+
+ _x = _spriteResource.getPosition().x + index * 30;
+ _y = _spriteResource.getPosition().y + 160;
+ StaticSprite::update();
+}
+
+Class606::Class606(NeverhoodEngine *vm, Scene *parentScene, int index, int surfacePriority, int16 x, int16 y, uint32 fileHash)
+ : StaticSprite(vm, fileHash, surfacePriority, x - 24, y - 4), _parentScene(parentScene), _index(index) {
+
+ if (!getSubVar(0x02038314, _index) && !getSubVar(0x02720344, _index)) {
+ SetMessageHandler(&Class606::handleMessage);
+ } else {
+ _surface->setVisible(false);
+ SetMessageHandler(NULL);
+ }
+ _deltaRect = _drawRect;
+ _deltaRect.x -= 4;
+ _deltaRect.y -= 8;
+ _deltaRect.width += 8;
+ _deltaRect.height += 16;
+ Sprite::processDelta();
+}
+
+uint32 Class606::handleMessage(int messageNum, const MessageParam &param, Entity *sender) {
+ uint32 messageResult = Sprite::handleMessage(messageNum, param, sender);
+ switch (messageNum) {
+ case 0x1011:
+ _parentScene->sendMessage(0x4826, 0, this);
+ messageResult = 1;
+ break;
+ case 0x4806:
+ setSubVar(0x02038314, _index, 1);
+ _surface->setVisible(false);
+ SetMessageHandler(NULL);
+ break;
+ }
+ return messageResult;
+}
+
+Scene1705::Scene1705(NeverhoodEngine *vm, Module *parentModule, int which)
+ : Scene(vm, parentModule, true), _paletteArea(1) {
+
+ Palette2 *palette2;
+ Sprite *tempSprite;
+
+ setGlobalVar(0xE7498218, 1);
+ // TODO _vm->initVarsScene1705();
+
+ SetMessageHandler(&Scene1705::handleMessage);
+ SetUpdateHandler(&Scene1705::update);
+
+ _vm->_collisionMan->setHitRects(0x004B69D8);
+
+ _surfaceFlag = true;
+
+ _background = addBackground(new DirtyBackground(_vm, 0x03118226, 0, 0));
+
+ palette2 = new Palette2(_vm, 0x03118226);
+ palette2->addPalette(0x91D3A391, 0, 64, 0);
+ palette2->copyBasePalette(0, 256, 0);
+ palette2->usePalette();
+ _palette = palette2;
+ addEntity(_palette);
+
+ _mouseCursor = addSprite(new Mouse433(_vm, 0x18222039, NULL));
+
+ addSprite(new Class602(_vm, kScene1705FileHashes[getSubVar(0x0A4C0A9A, 0)], 0));
+ addSprite(new Class602(_vm, kScene1705FileHashes[getSubVar(0x0A4C0A9A, 1)], 1));
+ addSprite(new Class602(_vm, kScene1705FileHashes[getSubVar(0x0A4C0A9A, 2)], 2));
+
+ _sprite = addSprite(new StaticSprite(_vm, 0x31313A22, 1100));
+
+ _class606 = addSprite(new Class606(_vm, this, 15, 1100, 238, 439, 0x02363852));
+ _vm->_collisionMan->addSprite(_class606);
+
+ which = 4;
+
+ if (which < 0) {
+ _klayman = new KmScene1705(_vm, this, 231, 434);
+ setMessageList(0x004B69E8);
+ sendMessage(0x2000, 0, this);
+ _klayman->getSurface()->getClipRect().x1 = 0;
+ _klayman->getSurface()->getClipRect().y1 = 0;
+ _klayman->getSurface()->getClipRect().x2 = _sprite->getSurface()->getDrawRect().x + _sprite->getSurface()->getDrawRect().width;
+ _klayman->getSurface()->getClipRect().y2 = 480;
+ } else if (which == 1) {
+ _klayman = new KmScene1705(_vm, this, 431, 434);
+ _klayman->sendMessage(0x2000, 1, this);
+ setMessageList(0x004B6A08);
+ sendMessage(0x2000, 1, this);
+ _klayman->getSurface()->getClipRect().x1 = 0;
+ _klayman->getSurface()->getClipRect().y1 = 0;
+ _klayman->getSurface()->getClipRect().x2 = _sprite->getSurface()->getDrawRect().x + _sprite->getSurface()->getDrawRect().width;
+ _klayman->getSurface()->getClipRect().y2 = 480;
+ } else if (which == 2) {
+ _klayman = new KmScene1705(_vm, this, 431, 434);
+ _klayman->sendMessage(0x2000, 1, this);
+ setMessageList(0x004B6AA0);
+ sendMessage(0x2000, 1, this);
+ _klayman->getSurface()->getClipRect().x1 = 0;
+ _klayman->getSurface()->getClipRect().y1 = 0;
+ _klayman->getSurface()->getClipRect().x2 = _sprite->getSurface()->getDrawRect().x + _sprite->getSurface()->getDrawRect().width;
+ _klayman->getSurface()->getClipRect().y2 = 480;
+ } else if (which == 3) {
+ _klayman = new KmScene1705(_vm, this, 431, 434);
+ _klayman->sendMessage(0x2000, 1, this);
+ setMessageList(0x004B6A18);
+ sendMessage(0x2000, 1, this);
+ _klayman->getSurface()->getClipRect().x1 = 0;
+ _klayman->getSurface()->getClipRect().y1 = 0;
+ _klayman->getSurface()->getClipRect().x2 = _sprite->getSurface()->getDrawRect().x + _sprite->getSurface()->getDrawRect().width;
+ _klayman->getSurface()->getClipRect().y2 = 480;
+ } else {
+ _klayman = new KmScene1705(_vm, this, 231, 74);
+ _klayman->sendMessage(0x2000, 0, this);
+ setMessageList(0x004B69F0);
+ sendMessage(0x2000, 0, this);
+ tempSprite = addSprite(new StaticSprite(_vm, 0x30303822, 1100));
+ _klayman->getSurface()->getClipRect().x1 = 0;
+ _klayman->getSurface()->getClipRect().y1 = tempSprite->getSurface()->getDrawRect().y;
+ _klayman->getSurface()->getClipRect().x2 = _sprite->getSurface()->getDrawRect().x + _sprite->getSurface()->getDrawRect().width;
+ _klayman->getSurface()->getClipRect().y2 = 480;
+ }
+
+ addSprite(_klayman);
+
+}
+
+void Scene1705::update() {
+ Scene::update();
+ if (_klayman->getX() < 224 && _paletteArea != 0) {
+ ((Palette2*)_palette)->addPalette(0xF2210C15, 0, 64, 0);
+ ((Palette2*)_palette)->startFadeToPalette(12);
+ _paletteArea = 0;
+ } else if (_klayman->getX() >= 224 && _paletteArea == 0) {
+ ((Palette2*)_palette)->addPalette(0x91D3A391, 0, 64, 0);
+ ((Palette2*)_palette)->startFadeToPalette(12);
+ _paletteArea = 1;
+ }
+}
+
+uint32 Scene1705::handleMessage(int messageNum, const MessageParam &param, Entity *sender) {
+ Scene::handleMessage(messageNum, param, sender);
+ switch (messageNum) {
+ case 0x2000:
+ if (param.asInteger()) {
+ setRectList(0x004B6B40);
+ _klayman->setKlaymanTable3();
+ } else {
+ setRectList(0x004B6B30);
+ _klayman->setKlaymanTable1();
+ }
+ break;
+ case 0x4826:
+ if (sender == _class606 && _klayman->getX() <= 318) {
+ _klayman->sendEntityMessage(0x1014, sender, this);
+ setMessageList(0x004B6AC0);
+ }
+ break;
+ }
+ return 0;
+}
+
+} // End of namespace Neverhood