diff options
author | johndoe123 | 2011-08-29 10:21:30 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-05-08 20:39:35 +0200 |
commit | eb8c44b54c846d30d9ce246b786fd46e1218b586 (patch) | |
tree | a68380df3da2fc5724134661506fcc63aac988b2 /engines | |
parent | bec86c7c2ee49a1428b5fac88b08e427805970a8 (diff) | |
download | scummvm-rg350-eb8c44b54c846d30d9ce246b786fd46e1218b586.tar.gz scummvm-rg350-eb8c44b54c846d30d9ce246b786fd46e1218b586.tar.bz2 scummvm-rg350-eb8c44b54c846d30d9ce246b786fd46e1218b586.zip |
NEVERHOOD: Implement Scene2201
- Implement DataResource::getHitRectList, DataResource::getMessageListAtPos and related stuff in scene.cpp
Diffstat (limited to 'engines')
-rw-r--r-- | engines/neverhood/gamemodule.cpp | 28 | ||||
-rw-r--r-- | engines/neverhood/gamemodule.h | 1 | ||||
-rw-r--r-- | engines/neverhood/klayman.cpp | 76 | ||||
-rw-r--r-- | engines/neverhood/klayman.h | 7 | ||||
-rw-r--r-- | engines/neverhood/module.mk | 1 | ||||
-rw-r--r-- | engines/neverhood/module2200.cpp | 730 | ||||
-rw-r--r-- | engines/neverhood/module2200.h | 206 | ||||
-rw-r--r-- | engines/neverhood/resource.cpp | 22 | ||||
-rw-r--r-- | engines/neverhood/scene.cpp | 51 | ||||
-rw-r--r-- | engines/neverhood/scene.h | 6 | ||||
-rw-r--r-- | engines/neverhood/staticdata.h | 2 |
11 files changed, 1115 insertions, 15 deletions
diff --git a/engines/neverhood/gamemodule.cpp b/engines/neverhood/gamemodule.cpp index 7408c25fbd..a118e4fb01 100644 --- a/engines/neverhood/gamemodule.cpp +++ b/engines/neverhood/gamemodule.cpp @@ -30,6 +30,7 @@ #include "neverhood/module1700.h" #include "neverhood/module1800.h" #include "neverhood/module2000.h" +#include "neverhood/module2200.h" #include "neverhood/module2300.h" #include "neverhood/module3000.h" @@ -236,10 +237,14 @@ void GameModule::startup() { _vm->gameState().sceneNum = 0; createModule1800(-1); #endif -#if 1 +#if 0 _vm->gameState().sceneNum = 0; createModule2000(-1); #endif +#if 1 + _vm->gameState().sceneNum = 0; + createModule2200(-1); +#endif } void GameModule::createModule1000(int which) { @@ -404,6 +409,25 @@ void GameModule::updateModule2000() { } } +void GameModule::createModule2200(int which) { + setGlobalVar(0x91080831, 0x11391412); + _childObject = new Module2200(_vm, this, which); + SetUpdateHandler(&GameModule::updateModule2200); +} + +void GameModule::updateModule2200() { + if (!_childObject) + return; + _childObject->handleUpdate(); + if (_done) { + _done = false; + delete _childObject; + _childObject = NULL; + createModule2300(1); + _childObject->handleUpdate(); + } +} + void GameModule::createModule2300(int which) { setGlobalVar(0x91080831, 0x1A214010); _childObject = new Module2300(_vm, this, which); @@ -419,7 +443,7 @@ void GameModule::updateModule2300() { delete _childObject; _childObject = NULL; if (_field20 == 1) { - // TODO createModule2200(0); + createModule2200(0); // TODO _childObject->handleUpdate(); } else if (_field20 == 2) { createModule1200(0); diff --git a/engines/neverhood/gamemodule.h b/engines/neverhood/gamemodule.h index 6de3893fbd..9ef1b92464 100644 --- a/engines/neverhood/gamemodule.h +++ b/engines/neverhood/gamemodule.h @@ -66,6 +66,7 @@ protected: void createModule2000(int which); void updateModule2000(); void createModule2200(int which); + void updateModule2200(); void createModule2300(int which); void updateModule2300(); void createModule2400(int which); diff --git a/engines/neverhood/klayman.cpp b/engines/neverhood/klayman.cpp index d74f94bbbf..50dd23101c 100644 --- a/engines/neverhood/klayman.cpp +++ b/engines/neverhood/klayman.cpp @@ -573,8 +573,10 @@ uint32 Klayman::handleMessage41D360(int messageNum, const MessageParam ¶m, E break; case 0x482C: if (param.asInteger() != 0) { + debug("#################################################"); // TODO _rectResource.getRectangle2(param.asInteger(), &_field118, &_field114,); } else { + debug("#################################################"); // TODO _field114 = 0; } break; @@ -3402,6 +3404,7 @@ uint32 KmScene2001::handleMessage4401A0(int messageNum, const MessageParam ¶ } break; } + return messageResult; } void KmScene2001::sub440230() { @@ -3422,4 +3425,77 @@ void KmScene2001::sub440270() { SetMessageHandler(&KmScene2001::handleMessage4401A0); } +KmScene2201::KmScene2201(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y, NRect *rect1, int16 unk) + // TODO: NRect *rect1, int16 unk in Klayman ctor + : Klayman(vm, parentScene, x, y, 1000, 1000) { + + _dataResource.load(0x04104242); + _flagF6 = false; +} + +uint32 KmScene2201::xHandleMessage(int messageNum, const MessageParam ¶m) { + switch (messageNum) { + case 0x4001: + case 0x4800: + sub41C930(param.asPoint().x, false); + break; + case 0x4004: + setCallback2(AnimationCallback(&Klayman::sub41FC80)); + break; + case 0x4812: + setCallback2(AnimationCallback(&Klayman::sub41FF80)); + break; + case 0x4816: + if (param.asInteger() == 0) { + setCallback2(AnimationCallback(&Klayman::sub4200D0)); + } + break; + case 0x4817: + setDoDeltaX(param.asInteger() ? 1 : 0); + sub41C7B0(); + break; + case 0x4818: + sub41C930(_dataResource.getPoint(param.asInteger()).x, false); + break; + case 0x481B: + if (param.asPoint().y != 0) { + sub41CC40(param.asPoint().y, param.asPoint().x); + } else { + sub41CCE0(param.asPoint().x); + } + break; + case 0x481D: + setCallback2(AnimationCallback(&Klayman::sub4207A0)); + break; + case 0x481E: + setCallback2(AnimationCallback(&Klayman::sub4207F0)); + break; + case 0x482D: + setDoDeltaX(_x > (int16)param.asInteger() ? 1 : 0); + sub41C7B0(); + break; + case 0x482E: + if (param.asInteger() == 1) { + setCallback2(AnimationCallback(&Klayman::sub421030)); + } else { + setCallback2(AnimationCallback(&Klayman::sub420FE0)); + } + break; + case 0x482F: + if (param.asInteger() == 1) { + setCallback2(AnimationCallback(&Klayman::sub4210C0)); + } else { + setCallback2(AnimationCallback(&Klayman::sub421070)); + } + break; + case 0x483F: + sub41CD00(param.asInteger()); + break; + case 0x4840: + sub41CD70(param.asInteger()); + break; + } + return 0; +} + } // End of namespace Neverhood diff --git a/engines/neverhood/klayman.h b/engines/neverhood/klayman.h index 8585689595..1c02f1e9cf 100644 --- a/engines/neverhood/klayman.h +++ b/engines/neverhood/klayman.h @@ -370,6 +370,13 @@ protected: void sub440270(); }; +class KmScene2201 : public Klayman { +public: + KmScene2201(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y, NRect *rect1, int16 unk); +protected: + uint32 xHandleMessage(int messageNum, const MessageParam ¶m); +}; + } // End of namespace Neverhood #endif /* NEVERHOOD_KLAYMAN_H */ diff --git a/engines/neverhood/module.mk b/engines/neverhood/module.mk index 5dcdc41aed..9122eaffab 100644 --- a/engines/neverhood/module.mk +++ b/engines/neverhood/module.mk @@ -18,6 +18,7 @@ MODULE_OBJS = \ module1700.o \ module1800.o \ module2000.o \ + module2200.o \ module2300.o \ module3000.o \ mouse.o \ diff --git a/engines/neverhood/module2200.cpp b/engines/neverhood/module2200.cpp new file mode 100644 index 0000000000..9e4d083b8d --- /dev/null +++ b/engines/neverhood/module2200.cpp @@ -0,0 +1,730 @@ +/* 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/module2200.h" +#include "neverhood/module1000.h" +#include "neverhood/module1200.h" + +namespace Neverhood { + +Module2200::Module2200(NeverhoodEngine *vm, Module *parentModule, int which) + : Module(vm, parentModule) { + + debug("Create Module2200(%d)", which); + + // TODO: Music18hList_add(0x11391412, 0x601C908C); + + if (which < 0) { + switch (_vm->gameState().sceneNum) { + default: + createScene2201(-1); + break; + case 1: + createScene2202(-1); + break; + case 2: + createScene2203(-1); + break; + case 3: + createScene2204(-1); + break; + case 4: + createScene2205(-1); + break; + case 5: + createScene2206(-1); + break; + case 6: + createScene2207(-1); + break; + case 7: + createScene2208(-1); + break; + case 8: + createScene2209(-1); + break; + case 9: + createScene2210(-1); + break; + case 10: + createScene2211(-1); + break; + case 11: + createScene2212(-1); + break; + case 12: + createScene2213(-1); + break; + case 13: + createScene2214(-1); + break; + case 14: + createScene2215(-1); + break; + case 15: + createScene2216(-1); + break; + case 16: + createScene2217(-1); + break; + case 17: + createScene2218(-1); + break; + case 18: + createScene2219(-1); + break; + case 19: + createScene2220(-1); + break; + case 20: + createScene2221(-1); + break; + case 21: + createScene2222(-1); + break; + case 22: + createScene2223(-1); + break; + case 23: + createScene2224(-1); + break; + case 24: + createScene2225(-1); + break; + case 25: + createScene2226(-1); + break; + case 26: + createScene2227(-1); + break; + case 27: + createScene2228(-1); + break; + case 28: + createScene2229(-1); + break; + case 29: + createScene2230(-1); + break; + case 30: + createScene2231(-1); + break; + case 31: + createScene2232(-1); + break; + case 32: + createScene2233(-1); + break; + case 33: + createScene2234(-1); + break; + case 34: + createScene2235(-1); + break; + case 35: + createScene2236(-1); + break; + case 36: + createScene2237(-1); + break; + case 37: + createScene2238(-1); + break; + case 38: + createScene2239(-1); + break; + case 39: + createScene2240(-1); + break; + case 40: + createScene2241(-1); + break; + case 41: + createScene2242(-1); + break; + case 42: + createScene2243(-1); + break; + case 43: + createScene2244(-1); + break; + case 44: + createScene2245(-1); + break; + case 45: + createScene2246(-1); + break; + case 46: + createScene2247(-1); + break; + case 47: + createScene2248(-1); + break; + } + } else { + createScene2201(0); + } + +} + +Module2200::~Module2200() { + // TODO Sound1ChList_sub_407A50(0x11391412); +} + +void Module2200::createScene2201(int which) { + _vm->gameState().sceneNum = 0; + _childObject = new Scene2201(_vm, this, which); + SetUpdateHandler(&Module2200::updateScene2201); +} + +void Module2200::createScene2202(int which) { +} + +void Module2200::createScene2203(int which) { +} + +void Module2200::createScene2204(int which) { +} + +void Module2200::createScene2205(int which) { +} + +void Module2200::createScene2206(int which) { +} + +void Module2200::createScene2207(int which) { +} + +void Module2200::createScene2208(int which) { +} + +void Module2200::createScene2209(int which) { +} + +void Module2200::createScene2210(int which) { +} + +void Module2200::createScene2211(int which) { +} + +void Module2200::createScene2212(int which) { +} + +void Module2200::createScene2213(int which) { +} + +void Module2200::createScene2214(int which) { +} + +void Module2200::createScene2215(int which) { +} + +void Module2200::createScene2216(int which) { +} + +void Module2200::createScene2217(int which) { +} + +void Module2200::createScene2218(int which) { +} + +void Module2200::createScene2219(int which) { +} + +void Module2200::createScene2220(int which) { +} + +void Module2200::createScene2221(int which) { +} + +void Module2200::createScene2222(int which) { +} + +void Module2200::createScene2223(int which) { +} + +void Module2200::createScene2224(int which) { +} + +void Module2200::createScene2225(int which) { +} + +void Module2200::createScene2226(int which) { +} + +void Module2200::createScene2227(int which) { +} + +void Module2200::createScene2228(int which) { +} + +void Module2200::createScene2229(int which) { +} + +void Module2200::createScene2230(int which) { +} + +void Module2200::createScene2231(int which) { +} + +void Module2200::createScene2232(int which) { +} + +void Module2200::createScene2233(int which) { +} + +void Module2200::createScene2234(int which) { +} + +void Module2200::createScene2235(int which) { +} + +void Module2200::createScene2236(int which) { +} + +void Module2200::createScene2237(int which) { +} + +void Module2200::createScene2238(int which) { +} + +void Module2200::createScene2239(int which) { +} + +void Module2200::createScene2240(int which) { +} + +void Module2200::createScene2241(int which) { +} + +void Module2200::createScene2242(int which) { +} + +void Module2200::createScene2243(int which) { +} + +void Module2200::createScene2244(int which) { +} + +void Module2200::createScene2245(int which) { +} + +void Module2200::createScene2246(int which) { +} + +void Module2200::createScene2247(int which) { +} + +void Module2200::createScene2248(int which) { +} + +void Module2200::updateScene2201() { + // TODO + _childObject->handleUpdate(); + if (_done) { + _done = false; + delete _childObject; + _childObject = NULL; + } +} + +void Module2200::updateScene2202() { +} + +void Module2200::updateScene2203() { +} + +void Module2200::updateScene2204() { +} + +void Module2200::updateScene2205() { +} + +void Module2200::updateScene2206() { +} + +void Module2200::updateScene2207() { +} + +void Module2200::updateScene2208() { +} + +void Module2200::updateScene2209() { +} + +void Module2200::updateScene2210() { +} + +void Module2200::updateScene2211() { +} + +void Module2200::updateScene2212() { +} + +void Module2200::updateScene2213() { +} + +void Module2200::updateScene2214() { +} + +void Module2200::updateScene2215() { +} + +void Module2200::updateScene2216() { +} + +void Module2200::updateScene2217() { +} + +void Module2200::updateScene2218() { +} + +void Module2200::updateScene2219() { +} + +void Module2200::updateScene2220() { +} + +void Module2200::updateScene2221() { +} + +void Module2200::updateScene2222() { +} + +void Module2200::updateScene2223() { +} + +void Module2200::updateScene2224() { +} + +void Module2200::updateScene2225() { +} + +void Module2200::updateScene2226() { +} + +void Module2200::updateScene2227() { +} + +void Module2200::updateScene2228() { +} + +void Module2200::updateScene2229() { +} + +void Module2200::updateScene2230() { +} + +void Module2200::updateScene2231() { +} + +void Module2200::updateScene2232() { +} + +void Module2200::updateScene2233() { +} + +void Module2200::updateScene2234() { +} + +void Module2200::updateScene2235() { +} + +void Module2200::updateScene2236() { +} + +void Module2200::updateScene2237() { +} + +void Module2200::updateScene2238() { +} + +void Module2200::updateScene2239() { +} + +void Module2200::updateScene2240() { +} + +void Module2200::updateScene2241() { +} + +void Module2200::updateScene2242() { +} + +void Module2200::updateScene2243() { +} + +void Module2200::updateScene2244() { +} + +void Module2200::updateScene2245() { +} + +void Module2200::updateScene2246() { +} + +void Module2200::updateScene2247() { +} + +void Module2200::updateScene2248() { +} + +// Scene2201 + +AsScene2201CeilingFan::AsScene2201CeilingFan(NeverhoodEngine *vm) + : AnimatedSprite(vm, 1100) { + + _x = 403; + _y = 259; + createSurface(100, 233, 96); + setFileHash(0x8600866, 0, -1); + SetUpdateHandler(&AnimatedSprite::update); +} + +AsScene2201Door::AsScene2201Door(NeverhoodEngine *vm, Klayman *klayman, Sprite *doorLightSprite, bool flag1) + : AnimatedSprite(vm, 1100), _soundResource(vm), _klayman(klayman), _doorLightSprite(doorLightSprite), + _countdown(0), _doorOpen(flag1) { + + _x = 408; + _y = 290; + createSurface(900, 63, 266); + SetUpdateHandler(&AsScene2201Door::update); + SetMessageHandler(&AsScene2201Door::handleMessage); + if (_doorOpen) { + setFileHash(0xE2CB0412, -1, -1); + _countdown = 48; + _newHashListIndex = -2; + } else { + setFileHash(0xE2CB0412, 0, -1); + _newHashListIndex = 0; + _doorLightSprite->getSurface()->setVisible(false); + } +} + +void AsScene2201Door::update() { + if (_countdown != 0 && _doorOpen && (--_countdown == 0)) { + stCloseDoor(); + } + AnimatedSprite::update(); +} + +uint32 AsScene2201Door::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { + uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); + switch (messageNum) { + case 0x100D: + if (param.asInteger() == 0x11001090) { + if (_doorOpen) + _doorLightSprite->getSurface()->setVisible(true); + } else if (param.asInteger() == 0x11283090) { + if (!_doorOpen) + _doorLightSprite->getSurface()->setVisible(false); + } + break; + case 0x2000: + if (_doorOpen) + _countdown = 144; + messageResult = _doorOpen ? 1 : 0; + break; + case 0x3002: + removeCallbacks(); + break; + case 0x4808: + _countdown = 144; + if (!_doorOpen) + stOpenDoor(); + break; + } + return messageResult; +} + +void AsScene2201Door::stOpenDoor() { + _doorOpen = true; + setFileHash(0xE2CB0412, 0, -1); + _newHashListIndex = -2; + _soundResource.play(calcHash("fxDoorOpen33")); +} + +void AsScene2201Door::stCloseDoor() { + _doorOpen = false; + setFileHash(0xE2CB0412, -1, -1); + _playBackwards = true; + _newHashListIndex = 0; + _soundResource.play(calcHash("fxDoorClose33")); +} + +Class444::Class444(NeverhoodEngine *vm, int pointIndex, int spriteIndex) + : StaticSprite(vm, 900) { + + _spriteResource.load2(kClass444FileHashes[spriteIndex]); + createSurface(100, 16, 16); + _drawRect.x = -(_spriteResource.getDimensions().width / 2); + _drawRect.y = -(_spriteResource.getDimensions().height / 2); + _drawRect.width = _spriteResource.getDimensions().width; + _drawRect.height = _spriteResource.getDimensions().height; + _x = kClass444Points[pointIndex].x; + _y = kClass444Points[pointIndex].y; + _needRefresh = true; +} + +Scene2201::Scene2201(NeverhoodEngine *vm, Module *parentModule, int which) + : Scene(vm, parentModule, true), _soundFlag(false) { + + Sprite *tempSprite; + + if (!getSubVar(0x40050052, 0x60400854)) { + // TODO _vm->gameModule()->initScene2201Vars(); + } + + _surfaceFlag = true; + SetMessageHandler(&Scene2201::handleMessage); + SetUpdateHandler(&Scene2201::update); + + loadDataResource(0x04104242); + loadHitRectList(); + + _background = addBackground(new DirtyBackground(_vm, 0x40008208, 0, 0)); + _palette = new Palette(_vm, 0x40008208); + _palette->usePalette(); + _mouseCursor = addSprite(new Mouse433(_vm, 0x0820C408, NULL)); + + _asTape = addSprite(new AsScene1201Tape(_vm, this, 7, 1100, 459, 432, 0x9148A011)); + _vm->_collisionMan->addSprite(_asTape); + + _ssDoorButton = addSprite(new Class426(_vm, this, 0xE4A43E29, 0xE4A43E29, 100, 0)); + + for (uint32 i = 0; i < 9; i++) { + if ((int16)getSubVar(0x484498D0, i) >= 0) { + addSprite(new Class444(_vm, i, (int16)getSubVar(0x484498D0, i))); + } + } + + _rect1.y1 = 0; + _rect1.x2 = 640; + _rect2.x2 = 640; + _rect2.y2 = 480; + + if (!getGlobalVar(0x404290D5)) { + addSprite(new StaticSprite(_vm, 0x00026027, 900)); + } + + tempSprite = addSprite(new StaticSprite(_vm, 0x030326A0, 1100)); + _rect1.x1 = tempSprite->getSurface()->getDrawRect().x; + + addSprite(new StaticSprite(_vm, 0x811DA061, 1100)); + + tempSprite = addSprite(new StaticSprite(_vm, 0x11180022, 1100)); + _rect2.x1 = tempSprite->getSurface()->getDrawRect().x; + + tempSprite = addSprite(new StaticSprite(_vm, 0x0D411130, 1100)); + _rect1.y2 = tempSprite->getSurface()->getDrawRect().y + tempSprite->getSurface()->getDrawRect().height; + _rect2.y1 = tempSprite->getSurface()->getDrawRect().y + tempSprite->getSurface()->getDrawRect().height; + + _doorLightSprite = addSprite(new StaticSprite(_vm, 0xA4062212, 900)); + + if (which < 0) { + _klayman = new KmScene2201(_vm, this, 300, 427, &_rect1, 2); + setMessageList(0x004B8118); + _asDoor = addSprite(new AsScene2201Door(_vm, _klayman, _doorLightSprite, false)); + } else if (which == 1) { + _klayman = new KmScene2201(_vm, this, 412, 393, &_rect1, 2); + setMessageList(0x004B8130); + _asDoor = addSprite(new AsScene2201Door(_vm, _klayman, _doorLightSprite, false)); + } else if (which == 2) { + if (getGlobalVar(0xC0418A02)) { + _klayman = new KmScene2201(_vm, this, 379, 427, &_rect1, 2); + _klayman->setDoDeltaX(1); + } else { + _klayman = new KmScene2201(_vm, this, 261, 427, &_rect1, 2); + } + setMessageList(0x004B8178); + _asDoor = addSprite(new AsScene2201Door(_vm, _klayman, _doorLightSprite, false)); + } else { + NPoint pt = _dataResource.getPoint(0x0304D8DC); + _klayman = new KmScene2201(_vm, this, pt.x, pt.y, &_rect1, 2); + setMessageList(0x004B8120); + _asDoor = addSprite(new AsScene2201Door(_vm, _klayman, _doorLightSprite, true)); + } + addSprite(_klayman); + + addSprite(new AsScene2201CeilingFan(_vm)); + + // TODO Sound1ChList_addSoundResource(0x04106220, 0x81212040, true); + +} + +Scene2201::~Scene2201() { + setGlobalVar(0xC0418A02, _klayman->isDoDeltaX() ? 1 : 0); + // TODO Sound1ChList_sub_407AF0(0x04106220); +} + +void Scene2201::update() { + Scene::update(); + if (!_soundFlag) { + // TODO Sound1ChList_playLooping(0x81212040); + _soundFlag = true; + } +} + +uint32 Scene2201::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { + Scene::handleMessage(messageNum, param, sender); + switch (messageNum) { + case 0x100D: + if (param.asInteger() == 0x402064D8) { + _klayman->sendEntityMessage(0x1014, _ssDoorButton, this); + } else if (param.asInteger() == 0x35803198) { + if (_asDoor->hasMessageHandler() && _asDoor->sendMessage(0x2000, 0, this)) { + setMessageList(0x004B81A0); + } else { + setMessageList(0x004B81B8); + } + } else if (param.asInteger() == 0x51445010) { + if (getGlobalVar(0x404290D5)) { + setMessageList(0x004B8108); + } else { + setMessageList(0x004B8150); + } + } else if (param.asInteger() == 0x1D203082) { + setMessageList(0x004B8180); + } else if (param.asInteger() == 0x00049091) { + if (getGlobalVar(0x404290D5)) { + setMessageList(0x004B8138); + } else { + setMessageList(0x004B8108); + } + } + break; + case 0x480B: + if (sender == _ssDoorButton) { + _asDoor->sendMessage(0x4808, 0, this); + } + break; + case 0x4826: + if (sender == _asTape) { + _klayman->sendEntityMessage(0x1014, _asTape, this); + setMessageList(0x004B81C8); + } + break; + } + return 0; +} + +} // End of namespace Neverhood diff --git a/engines/neverhood/module2200.h b/engines/neverhood/module2200.h new file mode 100644 index 0000000000..5b14606c4c --- /dev/null +++ b/engines/neverhood/module2200.h @@ -0,0 +1,206 @@ +/* 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. + * + */ + +#ifndef NEVERHOOD_MODULE2200_H +#define NEVERHOOD_MODULE2200_H + +#include "neverhood/neverhood.h" +#include "neverhood/module.h" +#include "neverhood/scene.h" + +namespace Neverhood { + +// Module2200 + +class Module2200 : public Module { +public: + Module2200(NeverhoodEngine *vm, Module *parentModule, int which); + virtual ~Module2200(); +protected: + void createScene2201(int which); + void createScene2202(int which); + void createScene2203(int which); + void createScene2204(int which); + void createScene2205(int which); + void createScene2206(int which); + void createScene2207(int which); + void createScene2208(int which); + void createScene2209(int which); + void createScene2210(int which); + void createScene2211(int which); + void createScene2212(int which); + void createScene2213(int which); + void createScene2214(int which); + void createScene2215(int which); + void createScene2216(int which); + void createScene2217(int which); + void createScene2218(int which); + void createScene2219(int which); + void createScene2220(int which); + void createScene2221(int which); + void createScene2222(int which); + void createScene2223(int which); + void createScene2224(int which); + void createScene2225(int which); + void createScene2226(int which); + void createScene2227(int which); + void createScene2228(int which); + void createScene2229(int which); + void createScene2230(int which); + void createScene2231(int which); + void createScene2232(int which); + void createScene2233(int which); + void createScene2234(int which); + void createScene2235(int which); + void createScene2236(int which); + void createScene2237(int which); + void createScene2238(int which); + void createScene2239(int which); + void createScene2240(int which); + void createScene2241(int which); + void createScene2242(int which); + void createScene2243(int which); + void createScene2244(int which); + void createScene2245(int which); + void createScene2246(int which); + void createScene2247(int which); + void createScene2248(int which); + void updateScene2201(); + void updateScene2202(); + void updateScene2203(); + void updateScene2204(); + void updateScene2205(); + void updateScene2206(); + void updateScene2207(); + void updateScene2208(); + void updateScene2209(); + void updateScene2210(); + void updateScene2211(); + void updateScene2212(); + void updateScene2213(); + void updateScene2214(); + void updateScene2215(); + void updateScene2216(); + void updateScene2217(); + void updateScene2218(); + void updateScene2219(); + void updateScene2220(); + void updateScene2221(); + void updateScene2222(); + void updateScene2223(); + void updateScene2224(); + void updateScene2225(); + void updateScene2226(); + void updateScene2227(); + void updateScene2228(); + void updateScene2229(); + void updateScene2230(); + void updateScene2231(); + void updateScene2232(); + void updateScene2233(); + void updateScene2234(); + void updateScene2235(); + void updateScene2236(); + void updateScene2237(); + void updateScene2238(); + void updateScene2239(); + void updateScene2240(); + void updateScene2241(); + void updateScene2242(); + void updateScene2243(); + void updateScene2244(); + void updateScene2245(); + void updateScene2246(); + void updateScene2247(); + void updateScene2248(); +}; + +// Scene2201 + +static const NPoint kClass444Points[] = { + {305, 305}, + {321, 305}, + {336, 305}, + {305, 319}, + {321, 319}, + {336, 319}, + {305, 332}, + {321, 332}, + {336, 333} +}; + +static const uint32 kClass444FileHashes[] = { + 0x88134A44, + 0xAA124340, + 0xB8124602, + 0xA902464C, + 0x890A4244, + 0xA8124642, + 0xB812C204, + 0x381A4A4C +}; + +class AsScene2201CeilingFan : public AnimatedSprite { +public: + AsScene2201CeilingFan(NeverhoodEngine *vm); +}; + +class AsScene2201Door : public AnimatedSprite { +public: + AsScene2201Door(NeverhoodEngine *vm, Klayman *klayman, Sprite *doorLightSprite, bool flag1); +protected: + SoundResource _soundResource; + Klayman *_klayman; + Sprite *_doorLightSprite; + bool _doorOpen; + int _countdown; + void update(); + uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender); + void stOpenDoor(); + void stCloseDoor(); +}; + +class Class444 : public StaticSprite { +public: + Class444(NeverhoodEngine *vm, int pointIndex, int spriteIndex); +}; + + +class Scene2201 : public Scene { +public: + Scene2201(NeverhoodEngine *vm, Module *parentModule, int which); + ~Scene2201(); +protected: + NRect _rect1; + NRect _rect2; + Sprite *_doorLightSprite; + Sprite *_asDoor; + Sprite *_ssDoorButton; + Sprite *_asTape; + bool _soundFlag; + void update(); + uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender); +}; + +} // End of namespace Neverhood + +#endif /* NEVERHOOD_MODULE2200_H */ diff --git a/engines/neverhood/resource.cpp b/engines/neverhood/resource.cpp index 39824de7f9..ef8e532ef1 100644 --- a/engines/neverhood/resource.cpp +++ b/engines/neverhood/resource.cpp @@ -497,7 +497,7 @@ void DataResource::load(uint32 fileHash) { hitRect.rect.y1 = dataS.readUint16LE(); hitRect.rect.x2 = dataS.readUint16LE(); hitRect.rect.y2 = dataS.readUint16LE(); - hitRect.type = dataS.readUint16LE(); + hitRect.type = dataS.readUint16LE() + 0x5001; debug(3, "(%d, %d, %d, %d) -> %04d", hitRect.rect.x1, hitRect.rect.y1, hitRect.rect.x2, hitRect.rect.y2, hitRect.type); hitRectList->push_back(hitRect); } @@ -514,7 +514,7 @@ void DataResource::load(uint32 fileHash) { MessageItem messageItem; messageItem.messageNum = dataS.readUint32LE(); messageItem.messageValue = dataS.readUint32LE(); - debug(3, "(%04X, %08X)", messageItem.messageNum, messageItem.messageValue); + debug(3, "(%08X, %08X)", messageItem.messageNum, messageItem.messageValue); messageList->push_back(messageItem); } drDirectoryItem.offset = _messageLists.size(); @@ -602,12 +602,26 @@ NPointArray *DataResource::getPointArray(uint32 nameHash) { } HitRectList *DataResource::getHitRectList() { - // TODO + DataResource::DRDirectoryItem *drDirectoryItem = findDRDirectoryItem(calcHash("HitArray"), 3); + if (drDirectoryItem) + return _hitRectLists[drDirectoryItem->offset]; return NULL; } MessageList *DataResource::getMessageListAtPos(int16 klaymanX, int16 klaymanY, int16 mouseX, int16 mouseY) { - // TODO + for (uint i = 0; i < _drRects.size(); i++) { + if (klaymanX >= _drRects[i].rect.x1 && klaymanX <= _drRects[i].rect.x2 && + klaymanY >= _drRects[i].rect.y1 && klaymanY <= _drRects[i].rect.y2) { + DRSubRectList *drSubRectList = _drSubRectLists[_drRects[i].subRectIndex]; + for (uint j = 0; j < drSubRectList->size(); j++) { + DRSubRect &subRect = (*drSubRectList)[j]; + if (mouseX >= subRect.rect.x1 && mouseX <= subRect.rect.x2 && + mouseY >= subRect.rect.y1 && mouseY <= subRect.rect.y2) { + return _messageLists[subRect.messageListItemIndex]; + } + } + } + } return NULL; } diff --git a/engines/neverhood/scene.cpp b/engines/neverhood/scene.cpp index 2c6b10ef4b..2a01bc2869 100644 --- a/engines/neverhood/scene.cpp +++ b/engines/neverhood/scene.cpp @@ -36,7 +36,6 @@ Scene::Scene(NeverhoodEngine *vm, Module *parentModule, bool clearHitRects) _mouseClickPos.y = 0; _mouseClicked = false; _rectList = NULL; - // TODO _someRects = NULL; _klayman = NULL; _mouseCursor = NULL; _palette = NULL; @@ -332,10 +331,10 @@ bool Scene::queryPositionSprite(int16 mouseX, int16 mouseY) { } bool Scene::queryPositionRectList(int16 mouseX, int16 mouseY) { + int16 klaymanX = _klayman->getX(); + int16 klaymanY = _klayman->getY(); if (_rectType == 1) { RectList &rectList = *_rectList; - int16 klaymanX = _klayman->getX(); - int16 klaymanY = _klayman->getY(); for (uint i = 0; i < rectList.size(); i++) { debug("(%d, %d) ? (%d, %d, %d, %d)", klaymanX, klaymanY, rectList[i].rect.x1, rectList[i].rect.y1, rectList[i].rect.x2, rectList[i].rect.y2); if (klaymanX >= rectList[i].rect.x1 && klaymanX <= rectList[i].rect.x2 && @@ -350,6 +349,10 @@ bool Scene::queryPositionRectList(int16 mouseX, int16 mouseY) { } } } + } else if (_rectType == 2) { + MessageList *messageList = _dataResource.getMessageListAtPos(klaymanX, klaymanY, mouseX, mouseY); + if (messageList && messageList->size()) + setMessageList2(messageList, true, true); } return true; } @@ -440,7 +443,7 @@ void Scene::runMessageList() { if (_messageList && _klayman) { while (_messageList && _messageListIndex < _messageListCount && !_messageListFlag1) { - int messageNum = (*_messageList)[_messageListIndex].messageNum; + uint32 messageNum = (*_messageList)[_messageListIndex].messageNum; uint32 messageParam = (*_messageList)[_messageListIndex].messageValue; debug("Scene::runMessageList() %04X, %08X", messageNum, messageParam); @@ -450,7 +453,7 @@ void Scene::runMessageList() { _klayman->sendMessage(0x1021, 0, this); } if (_systemCallbackFlag) { - // TODO messageNum = systemConvertMessageCb(messageNum); + messageNum = convertMessageNum(messageNum); } if (messageNum != 0x4003) { if (messageNum == 0x1009 || messageNum == 0x1024) { @@ -514,10 +517,48 @@ void Scene::clearRectList() { _rectType = 0; } +void Scene::loadHitRectList() { + HitRectList *hitRectList = _dataResource.getHitRectList(); + debug("Scene::loadHitRectList() hitRectList = %p", (void*)hitRectList); + if (hitRectList) { + _hitRectList = *hitRectList; + _vm->_collisionMan->setHitRects(&_hitRectList); + } +} + void Scene::loadDataResource(uint32 fileHash) { _dataResource.load(fileHash); + _rectType = 2; if (_klayman) _klayman->loadDataResource(fileHash); } +uint16 Scene::convertMessageNum(uint32 messageNum) { + switch (messageNum) { + case 0x00004004: + return 0x4001; + case 0x00000083: + return 0x100A; + case 0x044001C8: + return 0x481C; + case 0x02420480: + return 0x4818; + case 0x08004025: + return 0x100D; + case 0x04404281: + return 0x4824; + case 0x08400880: + return 0x4825; + case 0x08209081: + return 0x4823; + case 0x24000060: + return 0x1009; + case 0x42002200: + return 0x4004; + case 0x428D4894: + return 0x101A; + } + return 0x1000; +} + } // End of namespace Neverhood diff --git a/engines/neverhood/scene.h b/engines/neverhood/scene.h index ab5cf9f90e..e3ed273d42 100644 --- a/engines/neverhood/scene.h +++ b/engines/neverhood/scene.h @@ -65,10 +65,8 @@ protected: bool _mouseClicked; DataResource _dataResource; RectList *_rectList; + HitRectList _hitRectList; int _rectType; - // rectListCount - // TODO 00000088 someRects dd ? - // TODO 0000008C someRectsCount dw ? // TODO 0000008E field_8E dw ? Sprite *_mouseCursor; Klayman *_klayman; @@ -104,8 +102,10 @@ protected: void setRectList(uint32 id); void setRectList(RectList *rectList); void clearRectList(); + void loadHitRectList(); void messageList402220(); void loadDataResource(uint32 fileHash); + uint16 convertMessageNum(uint32 messageNum); }; } // End of namespace Neverhood diff --git a/engines/neverhood/staticdata.h b/engines/neverhood/staticdata.h index 178e5c9eb5..c19c060487 100644 --- a/engines/neverhood/staticdata.h +++ b/engines/neverhood/staticdata.h @@ -50,7 +50,7 @@ struct RectItem { typedef Common::Array<RectItem> RectList; struct MessageItem { - uint16 messageNum; + uint32 messageNum; uint32 messageValue; }; |