diff options
author | johndoe123 | 2011-09-09 09:04:28 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-05-08 20:39:36 +0200 |
commit | 9133d17cdf33a96fcb0423576e69d888323f2b00 (patch) | |
tree | 65563e6ff81b44cf15125fa0519aa5ae1ef77b5a /engines/neverhood | |
parent | 904f7ac33520a3b578ad46bb3b1552074ae57326 (diff) | |
download | scummvm-rg350-9133d17cdf33a96fcb0423576e69d888323f2b00.tar.gz scummvm-rg350-9133d17cdf33a96fcb0423576e69d888323f2b00.tar.bz2 scummvm-rg350-9133d17cdf33a96fcb0423576e69d888323f2b00.zip |
NEVERHOOD: Implement Scene2242
Diffstat (limited to 'engines/neverhood')
-rw-r--r-- | engines/neverhood/gamemodule.cpp | 2 | ||||
-rw-r--r-- | engines/neverhood/klayman.cpp | 95 | ||||
-rw-r--r-- | engines/neverhood/klayman.h | 11 | ||||
-rw-r--r-- | engines/neverhood/module2200.cpp | 156 | ||||
-rw-r--r-- | engines/neverhood/module2200.h | 12 |
5 files changed, 274 insertions, 2 deletions
diff --git a/engines/neverhood/gamemodule.cpp b/engines/neverhood/gamemodule.cpp index 920893c650..d9237b9f60 100644 --- a/engines/neverhood/gamemodule.cpp +++ b/engines/neverhood/gamemodule.cpp @@ -242,7 +242,7 @@ void GameModule::startup() { createModule2000(-1); #endif #if 1 - _vm->gameState().sceneNum = 7; + _vm->gameState().sceneNum = 41; createModule2200(-1); #endif } diff --git a/engines/neverhood/klayman.cpp b/engines/neverhood/klayman.cpp index 3e90cf13f6..a20f91b383 100644 --- a/engines/neverhood/klayman.cpp +++ b/engines/neverhood/klayman.cpp @@ -440,6 +440,14 @@ void Klayman::sub421310() { ///////////////////////////////////////////////////////////////// +void Klayman::sub41CE70() { + _x4 = _x; + if (!_flagE1 && !_flagE2 && !_flagE3) { + setCallback2(NULL); + sub41C7B0(); + } +} + void Klayman::sub41D320(uint32 fileHash, AnimationCb callback) { _resourceHandle = _vm->_res->useResource(fileHash); if (_resourceHandle != -1) { @@ -3751,7 +3759,7 @@ uint32 KmScene2206::xHandleMessage(int messageNum, const MessageParam ¶m) { } break; case 0x4837: - // TODO sub41CE70(); + sub41CE70(); break; case 0x483F: sub41CD00(param.asInteger()); @@ -3921,4 +3929,89 @@ void KmScene2207::sub4425A0() { SetMessageHandler(&Klayman::handleMessage41D360); } +KmScene2242::KmScene2242(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y) + : Klayman(vm, parentScene, x, y, 1000, 1000) { + // Empty +} + +void KmScene2242::xUpdate() { + setGlobalVar(0x18288913, _frameIndex); +} + +uint32 KmScene2242::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 0x4804: + if (param.asInteger() != 0) { + _x4 = param.asInteger(); + setCallback2(AnimationCallback(&KmScene2242::sub444D20)); + } else { + setCallback2(AnimationCallback(&Klayman::sub41FC40)); + } + 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 0x4817: + setDoDeltaX(param.asInteger()); + sub41C7B0(); + break; + case 0x481B: + if (param.asPoint().y != 0) { + sub41CC40(param.asPoint().y, param.asPoint().x); + } else { + sub41CCE0(param.asPoint().x); + } + break; + case 0x481F: + if (param.asInteger() == 0) { + setCallback2(AnimationCallback(&Klayman::sub420870)); + } else if (param.asInteger() == 1) { + setCallback2(AnimationCallback(&Klayman::sub4208B0)); + } else if (param.asInteger() == 3) { + setCallback2(AnimationCallback(&Klayman::sub4208F0)); + } else if (param.asInteger() == 4) { + setCallback2(AnimationCallback(&Klayman::sub420930)); + } else { + setCallback2(AnimationCallback(&Klayman::sub420830)); + } + break; + case 0x482D: + setDoDeltaX(_x > (int16)param.asInteger() ? 1 : 0); + sub41C7B0(); + break; + case 0x4837: + sub41CE70(); + break; + } + return 0; +} + +void KmScene2242::sub444D20() { + int16 frameIndex = (int16)getGlobalVar(0x18288913) + 1; + if (frameIndex < 0 || frameIndex > 13) + frameIndex = 0; + _status2 = 0; + _flagE1 = true; + _flagE5 = true; + setFileHash(0x1A249001, frameIndex, -1); + SetUpdateHandler(&Klayman::update); + SetMessageHandler(&Klayman::handleMessage41EB70); + SetSpriteCallback(&Klayman::spriteUpdate41F300); + SetAnimationCallback3(&Klayman::sub41FA40); + setCallback1(AnimationCallback(&Klayman::sub41FB30)); +} + } // End of namespace Neverhood diff --git a/engines/neverhood/klayman.h b/engines/neverhood/klayman.h index 7187905d66..a5abc0f520 100644 --- a/engines/neverhood/klayman.h +++ b/engines/neverhood/klayman.h @@ -113,6 +113,8 @@ public: void sub41F9E0(); void sub41FA40(); void sub41FB30(); + + void sub41CE70(); void spriteUpdate41F250(); void spriteUpdate41F5F0(); @@ -421,6 +423,15 @@ protected: void sub4425A0(); }; +class KmScene2242 : public Klayman { +public: + KmScene2242(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y); +protected: + void xUpdate(); + uint32 xHandleMessage(int messageNum, const MessageParam ¶m); + void sub444D20(); +}; + } // End of namespace Neverhood #endif /* NEVERHOOD_KLAYMAN_H */ diff --git a/engines/neverhood/module2200.cpp b/engines/neverhood/module2200.cpp index 2fb3eecc91..eb2829c279 100644 --- a/engines/neverhood/module2200.cpp +++ b/engines/neverhood/module2200.cpp @@ -248,6 +248,9 @@ void Module2200::createScene2208(int which) { } void Module2200::createScene2209(int which) { + _vm->gameState().sceneNum = 8; + _childObject = new Scene2208(_vm, this, which); + SetUpdateHandler(&Module2200::updateScene2209); } void Module2200::createScene2210(int which) { @@ -347,6 +350,9 @@ void Module2200::createScene2241(int which) { } void Module2200::createScene2242(int which) { + _vm->gameState().sceneNum = 41; + _childObject = new Scene2242(_vm, this, which); + SetUpdateHandler(&Module2200::updateScene2242); } void Module2200::createScene2243(int which) { @@ -487,6 +493,14 @@ void Module2200::updateScene2208() { } void Module2200::updateScene2209() { + _childObject->handleUpdate(); + if (_done) { + _done = false; + delete _childObject; + _childObject = NULL; + createScene2206(3); + _childObject->handleUpdate(); + } } void Module2200::updateScene2210() { @@ -586,6 +600,22 @@ void Module2200::updateScene2241() { } void Module2200::updateScene2242() { + _childObject->handleUpdate(); + if (_done) { + _done = false; + delete _childObject; + _childObject = NULL; + if (_field20 == 1) { + createScene2248(0); + _childObject->handleUpdate(); + } else if (_field20 == 2) { + createScene2208(0); + _childObject->handleUpdate(); + } else { + createScene2241(1); + _childObject->handleUpdate(); + } + } } void Module2200::updateScene2243() { @@ -2623,4 +2653,130 @@ void Scene2208::drawRow(int16 rowIndex) { } } +static const int16 kScene2242XPositions[] = { + 68, + 158 +}; + +static const uint32 kScene2242MessageListIds2[] = { + 0x004B3CB8, + 0x004B3CD8 +}; + +static const uint32 kScene2242MessageListIds1[] = { + 0x004B3CF8, + 0x004B3D20 +}; + +Scene2242::Scene2242(NeverhoodEngine *vm, Module *parentModule, int which) + : Scene(vm, parentModule, true), _isKlaymanInLight(false) { + + Palette2 *palette2; + + _surfaceFlag = true; + SetMessageHandler(&Scene2242::handleMessage); + SetUpdateHandler(&Scene2242::update); + + setGlobalVar(0x4D080E54,1); + + if (getGlobalVar(0x4D080E54)) { + _background = addBackground(new DirtyBackground(_vm, 0x11840E24, 0, 0)); + _palette = new Palette(_vm, 0x11840E24); + _palette->usePalette(); + _mouseCursor = addSprite(new Mouse433(_vm, 0x40E20110, NULL)); + setRectList(0x004B3DC8); + } else { + _background = addBackground(new DirtyBackground(_vm, 0x25848E24, 0, 0)); + palette2 = new Palette2(_vm, 0x25848E24); + _palette = palette2; + _palette->usePalette(); + addEntity(palette2); + ((Palette2*)_palette)->copyBasePalette(0, 256, 0); + _palette->addPalette(0x68033B1C, 0, 65, 0); + _mouseCursor = addSprite(new Mouse433(_vm, 0x48E20250, NULL)); + setRectList(0x004B3E18); + } + + _asTape = addSprite(new AsScene1201Tape(_vm, this, 10, 1100, 464, 435, 0x9148A011)); + _vm->_collisionMan->addSprite(_asTape); + + if (which < 0) { + _klayman = new KmScene2242(_vm, this, 200, 430); + setMessageList(0x004B3C18); + } else if (which == 1) { + _klayman = new KmScene2242(_vm, this, 530, 430); + setMessageList(0x004B3D60); + } else if (which == 2) { + _klayman = new KmScene2242(_vm, this, kScene2242XPositions[!getGlobalVar(0x48A68852) ? 0 : 1], 430); + setMessageList(0x004B3D48); + if (getGlobalVar(0xC0418A02)) + _klayman->setDoDeltaX(1); + } else { + _klayman = new KmScene2242(_vm, this, 0, 430); + setMessageList(0x004B3C20); + } + addSprite(_klayman); + + _klayman->setSoundFlag(true); + +} + +Scene2242::~Scene2242() { + setGlobalVar(0xC0418A02, _klayman->isDoDeltaX() ? 1 : 0); +} + +void Scene2242::update() { + if (!getGlobalVar(0x4D080E54)) { + if (_isKlaymanInLight && _klayman->getX() < 440) { + ((Palette2*)_palette)->addPalette(0x68033B1C, 0, 65, 0); + ((Palette2*)_palette)->startFadeToPalette(12); + _isKlaymanInLight = false; + } else if (!_isKlaymanInLight && _klayman->getX() >= 440) { + ((Palette2*)_palette)->addPalette(0x25848E24, 0, 65, 0); + ((Palette2*)_palette)->startFadeToPalette(12); + _isKlaymanInLight = true; + } + } + Scene::update(); +} + +uint32 Scene2242::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { + uint32 messageResult = Scene::handleMessage(messageNum, param, sender); + switch (messageNum) { + case 0x100D: + if (param.asInteger() == 0x800C6694) { + sub4448D0(); + } + break; + case 0x4826: + if (sender == _asTape) { + _klayman->sendEntityMessage(0x1014, _asTape, this); + setMessageList(0x004B3D50); + } + break; + } + return messageResult; +} + +void Scene2242::sub4448D0() { + int index; + if (_mouseClickPos.x < 108) { + setGlobalVar(0xC8C28808, 0x04290188); + setGlobalVar(0x48A68852, 42); + setGlobalVar(0x4CE79018, calcHash("bgRecPanelStart1")); + index = 0; + } else { + setGlobalVar(0xC8C28808, 0x04290188); + setGlobalVar(0x48A68852, 43); + setGlobalVar(0x4CE79018, calcHash("bgRecPanelStart2")); + index = 1; + } + setGlobalVar(0x49C40058, (_mouseClickPos.x - 100) / 7); + if (ABS(_klayman->getX() - kScene2242XPositions[index]) < 133) { + setMessageList2(kScene2242MessageListIds1[index]); + } else { + setMessageList2(kScene2242MessageListIds2[index]); + } +} + } // End of namespace Neverhood diff --git a/engines/neverhood/module2200.h b/engines/neverhood/module2200.h index 7a75e128f3..d06f30bf46 100644 --- a/engines/neverhood/module2200.h +++ b/engines/neverhood/module2200.h @@ -448,6 +448,18 @@ protected: void drawRow(int16 rowIndex); }; +class Scene2242 : public Scene { +public: + Scene2242(NeverhoodEngine *vm, Module *parentModule, int which); + ~Scene2242(); +protected: + Sprite *_asTape; + bool _isKlaymanInLight; + void update(); + uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender); + void sub4448D0(); +}; + } // End of namespace Neverhood #endif /* NEVERHOOD_MODULE2200_H */ |