diff options
author | johndoe123 | 2011-09-14 13:16:51 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-05-08 20:39:38 +0200 |
commit | 30ff790a0756466bfcd19b1193e9efb4e2bb377c (patch) | |
tree | d9feb67882d421241b4ea0144aee608949409321 | |
parent | 089ada55ba0eb1ba877921e9fd175ff16a9b7320 (diff) | |
download | scummvm-rg350-30ff790a0756466bfcd19b1193e9efb4e2bb377c.tar.gz scummvm-rg350-30ff790a0756466bfcd19b1193e9efb4e2bb377c.tar.bz2 scummvm-rg350-30ff790a0756466bfcd19b1193e9efb4e2bb377c.zip |
NEVERHOOD: Add Scene1306
-rw-r--r-- | engines/neverhood/gamemodule.cpp | 2 | ||||
-rw-r--r-- | engines/neverhood/klayman.cpp | 157 | ||||
-rw-r--r-- | engines/neverhood/klayman.h | 11 | ||||
-rw-r--r-- | engines/neverhood/module1300.cpp | 290 | ||||
-rw-r--r-- | engines/neverhood/module1300.h | 36 | ||||
-rw-r--r-- | engines/neverhood/sprite.h | 3 |
6 files changed, 497 insertions, 2 deletions
diff --git a/engines/neverhood/gamemodule.cpp b/engines/neverhood/gamemodule.cpp index 1487e8c9b2..93ea6c5066 100644 --- a/engines/neverhood/gamemodule.cpp +++ b/engines/neverhood/gamemodule.cpp @@ -247,7 +247,7 @@ void GameModule::startup() { createModule2200(-1); #endif #if 1 - _vm->gameState().sceneNum = 4; + _vm->gameState().sceneNum = 5; createModule1300(-1); #endif } diff --git a/engines/neverhood/klayman.cpp b/engines/neverhood/klayman.cpp index 3f03faad85..739c8ad6fa 100644 --- a/engines/neverhood/klayman.cpp +++ b/engines/neverhood/klayman.cpp @@ -3074,6 +3074,163 @@ void KmScene1305::sub46BF60() { sub41FC80(); } +KmScene1306::KmScene1306(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y) + : Klayman(vm, parentScene, x, y, 1000, 1000) { + + _flag1 = false; +} + +uint32 KmScene1306::xHandleMessage(int messageNum, const MessageParam ¶m) { + uint32 messageResult = 0; + switch (messageNum) { + case 0x2000: + _flag1 = param.asInteger() != 0; + break; + case 0x4001: + case 0x4800: + sub41C930(param.asPoint().x, false); + break; + case 0x4004: + if (_flag1) + setCallback2(AnimationCallback(&Klayman::sub421350)); + else + setCallback2(AnimationCallback(&Klayman::sub41FC80)); + break; + case 0x4812: + if (param.asInteger() == 2) { + setCallback2(AnimationCallback(&Klayman::sub420060)); + } else if (param.asInteger() == 1) { + setCallback2(AnimationCallback(&Klayman::sub41FFF0)); + } else { + setCallback2(AnimationCallback(&Klayman::sub41FF80)); + } + break; + case 0x4816: + if (param.asInteger() == 1) { + setCallback2(AnimationCallback(&Klayman::sub420120)); + } else if (param.asInteger() == 2) { + setCallback2(AnimationCallback(&Klayman::sub420170)); + } else { + setCallback2(AnimationCallback(&Klayman::sub4200D0)); + } + break; + case 0x4817: + setDoDeltaX(param.asInteger()); + sub41C7B0(); + break; + case 0x481A: + setCallback2(AnimationCallback(&Klayman::sub420680)); + break; + case 0x481B: + if (param.asPoint().y != 0) { + sub41CC40(param.asPoint().y, param.asPoint().x); + } else { + sub41CCE0(param.asPoint().x); + } + break; + case 0x481D: + if (_flag1) + setCallback2(AnimationCallback(&Klayman::sub4214D0)); + else + setCallback2(AnimationCallback(&Klayman::sub4207A0)); + break; + case 0x481E: + if (_flag1) + setCallback2(AnimationCallback(&Klayman::sub421510)); + else + setCallback2(AnimationCallback(&Klayman::sub4207F0)); + break; + case 0x481F: + if (param.asInteger() == 1) { + setCallback2(AnimationCallback(&Klayman::sub4208B0)); + } else if (param.asInteger() == 0) { + setCallback2(AnimationCallback(&Klayman::sub420870)); + } else if (param.asInteger() == 4) { + setCallback2(AnimationCallback(&Klayman::sub420930)); + } else if (param.asInteger() == 3) { + setCallback2(AnimationCallback(&Klayman::sub4208F0)); + } else { + setCallback2(AnimationCallback(&Klayman::sub420830)); + } + 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 0x4834: + setCallback2(AnimationCallback(&Klayman::sub421160)); + break; + case 0x4835: + _parentScene->sendMessage(0x2000, 1, this); + _flag1 = true; + setCallback2(AnimationCallback(&Klayman::sub4212C0)); + break; + case 0x4836: + _parentScene->sendMessage(0x2000, 0, this); + _flag1 = false; + setCallback2(AnimationCallback(&Klayman::sub421310)); + break; + case 0x483D: + sub417D40(); + break; + case 0x483E: + sub417D80(); + break; + case 0x483F: + sub41CD00(param.asInteger()); + break; + case 0x4840: + sub41CD70(param.asInteger()); + break; + } + return messageResult; +} + +void KmScene1306::sub417D40() { + _status2 = 0; + _flagE5 = false; + setFileHash(0xEE084A04, 0, -1); + SetUpdateHandler(&Klayman::update); + SetSpriteCallback(NULL); + SetMessageHandler(&KmScene1306::handleMessage417CB0); +} + +void KmScene1306::sub417D80() { + _status2 = 0; + _flagE5 = false; + setFileHash(0xB86A4274, 0, -1); + SetUpdateHandler(&Klayman::update); + SetSpriteCallback(NULL); + SetMessageHandler(&KmScene1306::handleMessage417CB0); +} + +uint32 KmScene1306::handleMessage417CB0(int messageNum, const MessageParam ¶m, Entity *sender) { + uint32 messageResult = handleMessage41D480(messageNum, param, sender); + switch (messageNum) { + case 0x100D: + if (param.asInteger() == 0x4E0A2C24) { + _soundResource1.play(0x85B10BB8); + } else if (param.asInteger() == 0x4E6A0CA0) { + _soundResource1.play(0xC5B709B0); + } + } + return messageResult; +} + // KmScene1401 KmScene1401::KmScene1401(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y) diff --git a/engines/neverhood/klayman.h b/engines/neverhood/klayman.h index c269e91ed0..118e8131e3 100644 --- a/engines/neverhood/klayman.h +++ b/engines/neverhood/klayman.h @@ -351,6 +351,17 @@ protected: void sub46BF60(); }; +class KmScene1306 : public Klayman { +public: + KmScene1306(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y); +protected: + bool _flag1; + uint32 xHandleMessage(int messageNum, const MessageParam ¶m); + uint32 handleMessage417CB0(int messageNum, const MessageParam ¶m, Entity *sender); + void sub417D40(); + void sub417D80(); +}; + class KmScene1401 : public Klayman { public: KmScene1401(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y); diff --git a/engines/neverhood/module1300.cpp b/engines/neverhood/module1300.cpp index 4814f41260..f437ddc730 100644 --- a/engines/neverhood/module1300.cpp +++ b/engines/neverhood/module1300.cpp @@ -22,6 +22,7 @@ #include "neverhood/module1300.h" #include "neverhood/module1000.h" +#include "neverhood/module1200.h" #include "neverhood/module2200.h" #include "neverhood/diskplayerscene.h" #include "neverhood/navigationscene.h" @@ -180,6 +181,11 @@ void Module1300::createScene1305(int which) { } void Module1300::createScene1306(int which) { + _vm->gameState().sceneNum = 5; + // TODO Sound1ChList_setSoundValuesMulti(dword_4B2868, false, 0, 0, 0, 0); + // TODO Music18hList_play(0x203197, 0, 2, 1); + _childObject = new Scene1306(_vm, this, which); + SetUpdateHandler(&Module1300::updateScene1306); } void Module1300::createScene1307(int which) { @@ -292,6 +298,24 @@ void Module1300::updateScene1305() { } void Module1300::updateScene1306() { + _childObject->handleUpdate(); + if (_done) { + _done = false; + delete _childObject; + _childObject = NULL; + if (_field20 == 2) { + createScene1309(0); + _childObject->handleUpdate(); + } else if (_field20 == 3) { + createScene1303(0); + _childObject->handleUpdate(); + } else if (_field20 == 0) { + _parentModule->sendMessage(0x1009, 0, this); + } else if (_field20 == 1) { + createScene1311(-1); + _childObject->handleUpdate(); + } + } } void Module1300::updateScene1307() { @@ -923,4 +947,270 @@ uint32 Scene1305::handleMessage(int messageNum, const MessageParam ¶m, Entit return Scene::handleMessage(messageNum, param, sender); } +AsScene1306Elevator::AsScene1306Elevator(NeverhoodEngine *vm, Scene *parentScene, AnimatedSprite *asElevatorDoor) + : AnimatedSprite(vm, 1100), _soundResource1(vm), _soundResource2(vm), _soundResource3(vm), + _parentScene(parentScene), _asElevatorDoor(asElevatorDoor), _isUp(false), _isDown(true), + _countdown(0) { + + _x = 320; + _y = 240; + createSurface1(0x043B0270, 100); + setFileHash(0x043B0270, 0, -1); + _newHashListIndex = 0; + SetMessageHandler(&AsScene1306Elevator::handleMessage); + _soundResource1.load(0x1C100E83); + _soundResource2.load(0x1C08CEC5); + _soundResource3.load(0x5D011E87); +} + +void AsScene1306Elevator::update() { + if (_isUp && _countdown != 0 && (--_countdown == 0)) { + stGoingDown(); + } + AnimatedSprite::update(); + if (_frameIndex == 7) { + _soundResource3.play(); + _asElevatorDoor->getSurface()->setVisible(false); + } +} + +void AsScene1306Elevator::upGoingDown() { + AnimatedSprite::update(); + if (_frameIndex == 5) { + _asElevatorDoor->getSurface()->setVisible(true); + } +} + +uint32 AsScene1306Elevator::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { + uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); + switch (messageNum) { + case 0x2001: + if (_isUp) + _countdown = 144; + messageResult = _isUp ? 1 : 0; + break; + case 0x3002: + removeCallbacks(); + break; + case 0x4808: + if (_isDown) + stGoingUp(); + break; + } + return messageResult; +} + +void AsScene1306Elevator::stGoingUp() { + _surface->setVisible(true); + _isDown = false; + SetUpdateHandler(&AsScene1306Elevator::update); + setFileHash(0x043B0270, 0, -1); + SetAnimationCallback3(&AsScene1306Elevator::cbGoingUpEvent); + _soundResource1.play(); +} + +void AsScene1306Elevator::cbGoingUpEvent() { + SetUpdateHandler(&AsScene1306Elevator::update); + _parentScene->sendMessage(0x4808, 0, this); + _isUp = true; + _countdown = 144; + setFileHash1(); + _surface->setVisible(false); +} + +void AsScene1306Elevator::stGoingDown() { + SetUpdateHandler(&AsScene1306Elevator::upGoingDown); + _isUp = false; + _surface->setVisible(true); + setFileHash(0x043B0270, -1, -1); + _playBackwards = true; + SetAnimationCallback3(&AsScene1306Elevator::cbGoingDownEvent); + _soundResource2.play(); +} + +void AsScene1306Elevator::cbGoingDownEvent() { + _isDown = true; + _parentScene->sendMessage(0x4809, 0, this); + SetUpdateHandler(&AsScene1306Elevator::update); + setFileHash1(); +} + +Scene1306::Scene1306(NeverhoodEngine *vm, Module *parentModule, int which) + : Scene(vm, parentModule, true) { + + if (getGlobalVar(0xC0780812) && !getGlobalVar(0x13382860)) + setGlobalVar(0x13382860, 4); + + _surfaceFlag = true; + SetMessageHandler(&Scene1306::handleMessage); + + _background = addBackground(new DirtyBackground(_vm, 0x05303114, 0, 0)); + _palette = new Palette(_vm, 0x05303114); + _palette->usePalette(); + _mouseCursor = addSprite(new Mouse433(_vm, 0x0311005B, NULL)); + + if (!getGlobalVar(0x13382860)) { + _class545 = addSprite(new Class545(_vm, this, 2, 1100, 435, 445)); + _vm->_collisionMan->addSprite(_class545); + } + + _ssButton = addSprite(new SsCommonButtonSprite(_vm, this, 0x404A36A0, 100, 0x440C1000)); + + _asTape = addSprite(new AsScene1201Tape(_vm, this, 19, 1100, 359, 445, 0x9148A011)); + + _asElevatorDoor = new AnimatedSprite(_vm, 0x043B0270, 90, 320, 240); + _asElevatorDoor->setFileHash(0x043B0270, 6, -1); + _asElevatorDoor->setNewHashListIndex(6); + addSprite(_asElevatorDoor); + + _asElevator = addSprite(new AsScene1306Elevator(_vm, this, _asElevatorDoor)); + + _sprite1 = addSprite(new StaticSprite(_vm, 0x036A1EE0, 80)); + + addSprite(new StaticSprite(_vm, 0x00042313, 1100)); + + if (which < 0) { + _klayman = new KmScene1306(_vm, this, 380, 440); + setMessageList(0x004AFAD0); + sendMessage(0x2000, 0, this); + _vm->_collisionMan->addSprite(_asTape); + } else if (which == 1) { + _klayman = new KmScene1306(_vm, this, 136, 440); + _klayman->sendMessage(0x2000, 1, this); + setMessageList(0x004AFAF0); + sendMessage(0x2000, 1, this); + _vm->_collisionMan->addSprite(_asTape); + } else if (which == 2) { + if (getGlobalVar(0xC0418A02)) { + _klayman = new KmScene1306(_vm, this, 515, 440); + _klayman->setDoDeltaX(1); + } else { + _klayman = new KmScene1306(_vm, this, 355, 440); + } + setMessageList(0x004AFBC8); + sendMessage(0x2000, 0, this); + _vm->_collisionMan->addSprite(_asTape); + } else if (which == 3) { + _klayman = new KmScene1306(_vm, this, 534, 440); + setMessageList(0x004AFC30); + sendMessage(0x2000, 0, this); + _vm->_collisionMan->addSprite(_asTape); + } else if (which == 4) { + _klayman = new KmScene1306(_vm, this, 136, 440); + _klayman->sendMessage(0x2000, 1, this); + setMessageList(0x004AFC38); + sendMessage(0x2000, 1, this); + _vm->_collisionMan->addSprite(_asTape); + } else if (which == 5) { + _klayman = new KmScene1306(_vm, this, 136, 440); + _klayman->sendMessage(0x2000, 1, this); + setMessageList(0x004AFB00); + sendMessage(0x2000, 1, this); + _vm->_collisionMan->addSprite(_asTape); + } else { + _klayman = new KmScene1306(_vm, this, 286, 408); + setSurfacePriority(_asElevator->getSurface(), 1100); + setSurfacePriority(_asElevatorDoor->getSurface(), 1090); + setSurfacePriority(_sprite1->getSurface(), 1080); + sendMessage(0x2000, 0, this); + SetMessageHandler(&Scene1306::handleMessage416EB0); + clearRectList(); + _asElevator->sendMessage(0x4808, 0, this); + } + addSprite(_klayman); + +} + +Scene1306::~Scene1306() { + setGlobalVar(0xC0418A02, _klayman->isDoDeltaX() ? 1 : 0); +} + +uint32 Scene1306::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { +if (messageNum) debug("%04X", messageNum); + Scene::handleMessage(messageNum, param, sender); + switch (messageNum) { + case 0x100D: + if (param.asInteger() == 0x402064D8) { + _klayman->sendEntityMessage(0x1014, _ssButton, this); + } else if (param.asInteger() == 0x01C66840) { + if (_asElevator->sendMessage(0x2001, 0, this) != 0) { + setMessageList(0x004AFBD8); + } else { + setMessageList(0x004AFAE0); + } + } else if (param.asInteger() == 0x8E646E00) { + setMessageList(0x004AFAD8); + clearRectList(); + SetMessageHandler(&Scene1306::handleMessage416EB0); + } + break; + case 0x2000: + if (param.asInteger() != 0) { + setRectList(0x004AFD28); + _klayman->setKlaymanTable3(); + } else { + setRectList(0x004AFD18); + _klayman->setKlaymanTable1(); + } + break; + case 0x480B: + if (sender == _ssButton) { + _asElevator->sendMessage(0x4808, 0, this); + } + break; + case 0x4826: + if (sender == _class545) { + if (_klayman->getX() >= 249) { + _klayman->sendEntityMessage(0x1014, _class545, this); + setMessageList(0x004AFC58); + } + } else if (sender == _asTape) { + if (_klayman->getX() >= 249) { + _klayman->sendEntityMessage(0x1014, _class545, this); + setMessageList(0x004AFC68); + } + } + break; + case 0x482A: + setSurfacePriority(_asElevator->getSurface(), 1100); + setSurfacePriority(_asElevatorDoor->getSurface(), 1090); + setSurfacePriority(_sprite1->getSurface(), 1080); + break; + case 0x482B: + setSurfacePriority(_asElevator->getSurface(), 100); + setSurfacePriority(_asElevatorDoor->getSurface(), 90); + setSurfacePriority(_sprite1->getSurface(), 80); + sendMessage(0x2000, 0, this); + _vm->_collisionMan->addSprite(_asTape); + break; + } + return 0; +} + +uint32 Scene1306::handleMessage416EB0(int messageNum, const MessageParam ¶m, Entity *sender) { + Scene::handleMessage(messageNum, param, sender); + switch (messageNum) { + case 0x4808: + setMessageList(0x004AFBD0); + SetMessageHandler(&Scene1306::handleMessage); + break; + case 0x4809: + _parentModule->sendMessage(0x1009, 1, this); + break; + case 0x482A: + setSurfacePriority(_asElevator->getSurface(), 1100); + setSurfacePriority(_asElevatorDoor->getSurface(), 1090); + setSurfacePriority(_sprite1->getSurface(), 1080); + break; + case 0x482B: + setSurfacePriority(_asElevator->getSurface(), 100); + setSurfacePriority(_asElevatorDoor->getSurface(), 90); + setSurfacePriority(_sprite1->getSurface(), 80); + sendMessage(0x2000, 0, this); + _vm->_collisionMan->addSprite(_asTape); + break; + } + return 0; +} + } // End of namespace Neverhood diff --git a/engines/neverhood/module1300.h b/engines/neverhood/module1300.h index 03e3d6e92d..33f5fb5c9f 100644 --- a/engines/neverhood/module1300.h +++ b/engines/neverhood/module1300.h @@ -172,6 +172,42 @@ protected: uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender); }; +class AsScene1306Elevator : public AnimatedSprite { +public: + AsScene1306Elevator(NeverhoodEngine *vm, Scene *parentScene, AnimatedSprite *asElevatorDoor); +protected: + Scene *_parentScene; + AnimatedSprite *_asElevatorDoor; + SoundResource _soundResource1; + SoundResource _soundResource2; + SoundResource _soundResource3; + bool _isUp; + bool _isDown; + int _countdown; + void update(); + void upGoingDown(); + uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender); + void stGoingUp(); + void cbGoingUpEvent(); + void stGoingDown(); + void cbGoingDownEvent(); +}; + +class Scene1306 : public Scene { +public: + Scene1306(NeverhoodEngine *vm, Module *parentModule, int which); + ~Scene1306(); +protected: + Sprite *_ssButton; + Sprite *_asTape; + AnimatedSprite *_asElevatorDoor; + Sprite *_asElevator; + Sprite *_sprite1; + Sprite *_class545; + uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender); + uint32 handleMessage416EB0(int messageNum, const MessageParam ¶m, Entity *sender); +}; + } // End of namespace Neverhood #endif /* NEVERHOOD_MODULE1300_H */ diff --git a/engines/neverhood/sprite.h b/engines/neverhood/sprite.h index 7ec5d9124a..16d79319fd 100644 --- a/engines/neverhood/sprite.h +++ b/engines/neverhood/sprite.h @@ -114,6 +114,8 @@ public: void clearRepl(); uint32 getCurrAnimFileHash() const { return _currAnimFileHash; } int16 getFrameIndex() const { return _frameIndex; } + void setNewHashListIndex(int value) { _newHashListIndex = value; } + void setFileHash(uint32 fileHash, int16 frameIndex3, int16 frameIndex4); protected: typedef void (AnimatedSprite::*AnimationCb)(); AnimResource _animResource; @@ -154,7 +156,6 @@ protected: void updateFrameIndex(); void updateFrameInfo(); void createSurface1(uint32 fileHash, int surfacePriority); - void setFileHash(uint32 fileHash, int16 frameIndex3, int16 frameIndex4); void setFileHash1(); void setFileHash2(uint32 fileHash, uint32 fileHash6, uint32 fileHash5); void setFileHash3(uint32 fileHash2, uint32 fileHash6, uint32 fileHash5); |