diff options
author | johndoe123 | 2011-09-01 10:18:49 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-05-08 20:39:35 +0200 |
commit | e177dcf911fc7034faef9c378f7b95f2355ec66b (patch) | |
tree | 4c8b27750503c9a086690681ddcc7ae0203f3491 /engines/neverhood | |
parent | 732f7c8845bf694e30f3d8c1ffe4b33a5a06a7c7 (diff) | |
download | scummvm-rg350-e177dcf911fc7034faef9c378f7b95f2355ec66b.tar.gz scummvm-rg350-e177dcf911fc7034faef9c378f7b95f2355ec66b.tar.bz2 scummvm-rg350-e177dcf911fc7034faef9c378f7b95f2355ec66b.zip |
NEVERHOOD: Implement Scene2205
Diffstat (limited to 'engines/neverhood')
-rw-r--r-- | engines/neverhood/gamemodule.cpp | 2 | ||||
-rw-r--r-- | engines/neverhood/klayman.cpp | 63 | ||||
-rw-r--r-- | engines/neverhood/klayman.h | 22 | ||||
-rw-r--r-- | engines/neverhood/module1000.cpp | 26 | ||||
-rw-r--r-- | engines/neverhood/module1000.h | 2 | ||||
-rw-r--r-- | engines/neverhood/module2200.cpp | 180 | ||||
-rw-r--r-- | engines/neverhood/module2200.h | 20 | ||||
-rw-r--r-- | engines/neverhood/mouse.h | 6 |
8 files changed, 310 insertions, 11 deletions
diff --git a/engines/neverhood/gamemodule.cpp b/engines/neverhood/gamemodule.cpp index daa0555c84..fd603a8972 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 = 2; + _vm->gameState().sceneNum = 4; createModule2200(-1); #endif } diff --git a/engines/neverhood/klayman.cpp b/engines/neverhood/klayman.cpp index 8eab4a2e36..404cce5e76 100644 --- a/engines/neverhood/klayman.cpp +++ b/engines/neverhood/klayman.cpp @@ -3595,4 +3595,67 @@ uint32 KmScene2203::xHandleMessage(int messageNum, const MessageParam ¶m) { return 0; } +KmScene2205::KmScene2205(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y) + : Klayman(vm, parentScene, x, y, 1000, 1000) { + // Empty +} + +void KmScene2205::xUpdate() { + setGlobalVar(0x18288913, _frameIndex); +} + +uint32 KmScene2205::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(&KmScene2205::sub423980)); + } else { + setCallback2(AnimationCallback(&Klayman::sub41FC40)); + } + break; + case 0x4816: + if (param.asInteger() == 0) { + setCallback2(AnimationCallback(&Klayman::sub4200D0)); + } + break; + case 0x4817: + setDoDeltaX(param.asInteger()); + sub41C7B0(); + break; + case 0x4818: + sub41C930(_dataResource.getPoint(param.asInteger()).x, false); + break; + case 0x483F: + sub41CD00(param.asInteger()); + break; + case 0x4840: + sub41CD70(param.asInteger()); + break; + } + return 0; +} + +void KmScene2205::sub423980() { + int16 frameIndex = getGlobalVar(0x18288913); + 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 8ca56cc5d9..d9d63b1011 100644 --- a/engines/neverhood/klayman.h +++ b/engines/neverhood/klayman.h @@ -111,20 +111,27 @@ public: void sub420EB0(); void sub420680(); void sub41F9E0(); + void sub41FA40(); + void sub41FB30(); void spriteUpdate41F250(); void spriteUpdate41F5F0(); void spriteUpdate41F780(); void spriteUpdate41F230(); void spriteUpdate41F5A0(); + void spriteUpdate41F300(); + void spriteUpdate41F320(); uint32 handleMessage41D360(int messageNum, const MessageParam ¶m, Entity *sender); uint32 handleMessage41D480(int messageNum, const MessageParam ¶m, Entity *sender); + uint32 handleMessage41EB70(int messageNum, const MessageParam ¶m, Entity *sender); void setKlaymanTable(const KlaymanTableItem *table, int tableCount); void setKlaymanTable1(); void setKlaymanTable2(); void setKlaymanTable3(); + + void setSoundFlag(bool value) { _soundFlag = value; } protected: Entity *_parentScene; @@ -204,14 +211,8 @@ protected: uint32 handleMessage41DD80(int messageNum, const MessageParam ¶m, Entity *sender); void sub41CD70(int16 x); void sub41F950(); - void sub41FB30(); uint32 handleMessage41EC70(int messageNum, const MessageParam ¶m, Entity *sender); - void spriteUpdate41F300(); - uint32 handleMessage41EB70(int messageNum, const MessageParam ¶m, Entity *sender); - void sub41FA40(); - void spriteUpdate41F320(); - uint32 handleMessage41E210(int messageNum, const MessageParam ¶m, Entity *sender); uint32 handleMessage41D4C0(int messageNum, const MessageParam ¶m, Entity *sender); @@ -386,6 +387,15 @@ protected: uint32 xHandleMessage(int messageNum, const MessageParam ¶m); }; +class KmScene2205 : public Klayman { +public: + KmScene2205(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y); + void sub423980(); +protected: + void xUpdate(); + uint32 xHandleMessage(int messageNum, const MessageParam ¶m); +}; + } // End of namespace Neverhood #endif /* NEVERHOOD_KLAYMAN_H */ diff --git a/engines/neverhood/module1000.cpp b/engines/neverhood/module1000.cpp index 8ee5941d95..69c6014aa2 100644 --- a/engines/neverhood/module1000.cpp +++ b/engines/neverhood/module1000.cpp @@ -972,6 +972,32 @@ Class426::Class426(NeverhoodEngine *vm, Scene *parentScene, uint32 fileHash1, ui } +void Class426::setFileHashes(uint32 fileHash1, uint32 fileHash2) { + _fileHashes[0] = fileHash1; + _fileHashes[1] = fileHash2; + if (_status == 2) { + _spriteResource.load2(fileHash2); + _surface->getDrawRect().x = 0; + _surface->getDrawRect().y = 0; + _surface->getDrawRect().width = _spriteResource.getDimensions().width; + _surface->getDrawRect().height = _spriteResource.getDimensions().height; + _x = _spriteResource.getPosition().x; + _y = _spriteResource.getPosition().y; + _needRefresh = true; + StaticSprite::update(); + } else { + _spriteResource.load2(fileHash1); + _surface->getDrawRect().x = 0; + _surface->getDrawRect().y = 0; + _surface->getDrawRect().width = _spriteResource.getDimensions().width; + _surface->getDrawRect().height = _spriteResource.getDimensions().height; + _x = _spriteResource.getPosition().x; + _y = _spriteResource.getPosition().y; + _needRefresh = true; + StaticSprite::update(); + } +} + void Class426::update() { if (_countdown != 0 && (--_countdown) == 0) { if (_status == 1) { diff --git a/engines/neverhood/module1000.h b/engines/neverhood/module1000.h index 0e3f950c3e..5229e7a083 100644 --- a/engines/neverhood/module1000.h +++ b/engines/neverhood/module1000.h @@ -202,7 +202,7 @@ protected: class Class426 : public StaticSprite { public: Class426(NeverhoodEngine *vm, Scene *parentScene, uint32 fileHash1, uint32 fileHash2, int surfacePriority, uint32 soundFileHash); - // TODO Class426_sub433660 (not used yet) + void setFileHashes(uint32 fileHash1, uint32 fileHash2); protected: Scene *_parentScene; int _countdown; diff --git a/engines/neverhood/module2200.cpp b/engines/neverhood/module2200.cpp index e8fd77dc18..e7e025750f 100644 --- a/engines/neverhood/module2200.cpp +++ b/engines/neverhood/module2200.cpp @@ -219,6 +219,10 @@ void Module2200::createScene2204(int which) { } void Module2200::createScene2205(int which) { + _vm->gameState().sceneNum = 4; + // TODO Music18hList_stop(0x601C908C, 0, 2); + _childObject = new Scene2205(_vm, this, 3); + SetUpdateHandler(&Module2200::updateScene2205); } void Module2200::createScene2206(int which) { @@ -406,6 +410,22 @@ void Module2200::updateScene2204() { } void Module2200::updateScene2205() { + _childObject->handleUpdate(); + if (_done) { + _done = false; + delete _childObject; + _childObject = NULL; + if (_field20 == 1) { + createScene2206(0); + _childObject->handleUpdate(); + } else if (_field20 == 2) { + createScene2205(2); + _childObject->handleUpdate(); + } else { + createScene2203(1); + _childObject->handleUpdate(); + } + } } void Module2200::updateScene2206() { @@ -1387,4 +1407,164 @@ uint32 Scene2203::handleMessage(int messageNum, const MessageParam ¶m, Entit return messageResult; } +SsScene2205DoorFrame::SsScene2205DoorFrame(NeverhoodEngine *vm) + : StaticSprite(vm, 900) { + + SetMessageHandler(&SsScene2205DoorFrame::handleMessage); + _spriteResource.load2(getGlobalVar(0x4D080E54) ? 0x24306227 : 0xD90032A0); + createSurface(1100, 45, 206); + _drawRect.x = 0; + _drawRect.y = 0; + _drawRect.width = _spriteResource.getDimensions().width; + _drawRect.height = _spriteResource.getDimensions().height; + _x = _spriteResource.getPosition().x; + _y = _spriteResource.getPosition().y; + _needRefresh = true; + StaticSprite::update(); +} + +uint32 SsScene2205DoorFrame::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { + uint32 messageResult = Sprite::handleMessage(messageNum, param, sender); + switch (messageNum) { + case 0x2000: + _spriteResource.load2(getGlobalVar(0x4D080E54) ? 0x24306227 : 0xD90032A0); + _drawRect.x = 0; + _drawRect.y = 0; + _drawRect.width = _spriteResource.getDimensions().width; + _drawRect.height = _spriteResource.getDimensions().height; + _x = _spriteResource.getPosition().x; + _y = _spriteResource.getPosition().y; + _needRefresh = true; + StaticSprite::update(); + } + return messageResult; +} + +Scene2205::Scene2205(NeverhoodEngine *vm, Module *parentModule, int which) + : Scene(vm, parentModule, true) { + + Palette2 *palette2; + + SetMessageHandler(&Scene2205::handleMessage); + SetUpdateHandler(&Scene2205::update); + + _vm->_collisionMan->setHitRects(0x004B0620); + _surfaceFlag = true; + + if (getGlobalVar(0x4D080E54)) { + _isLightOn = true; + _background = addBackground(new DirtyBackground(_vm, 0x0008028D, 0, 0)); + palette2 = new Palette2(_vm, 0x0008028D); + _palette = palette2; + _palette->usePalette(); + addEntity(palette2); + _mouseCursor = addSprite(new Mouse433(_vm, 0x80289008, NULL)); + _ssLightSwitch = new Class426(_vm, this, 0x2D339030, 0x2D309030, 100, 0); + addSprite(_ssLightSwitch); + } else { + _isLightOn = false; + _background = addBackground(new DirtyBackground(_vm, 0xD00A028D, 0, 0)); + palette2 = new Palette2(_vm, 0xD00A028D); + _palette = palette2; + _palette->usePalette(); + addEntity(palette2); + _mouseCursor = addSprite(new Mouse433(_vm, 0xA0289D08, NULL)); + _ssLightSwitch = new Class426(_vm, this, 0x2D339030, 0xDAC86E84, 100, 0); + addSprite(_ssLightSwitch); + } + + palette2->addPalette(0xD00A028D, 0, 256, 0); + + _ssDoorFrame = addSprite(new SsScene2205DoorFrame(_vm)); + + if (which < 0) { + _klayman = new KmScene2205(_vm, this, 320, 417); + setMessageList(0x004B0658); + if (!getGlobalVar(0x4D080E54)) { + _palette->addPalette(0x68033B1C, 0, 65, 0); + } + _isKlaymanInLight = false; + } else if (which == 1) { + _klayman = new KmScene2205(_vm, this, 640, 417); + setMessageList(0x004B0648); + if (!getGlobalVar(0x4D080E54)) { + _palette->addPalette(0x68033B1C, 0, 65, 0); + } + _isKlaymanInLight = false; + } else { + _klayman = new KmScene2205(_vm, this, 0, 417); + setMessageList(0x004B0640); + _isKlaymanInLight = true; + } + addSprite(_klayman); + + _klayman->getSurface()->getClipRect().x1 = _ssDoorFrame->getSurface()->getDrawRect().x; + _klayman->getSurface()->getClipRect().y1 = 0; + _klayman->getSurface()->getClipRect().x2 = 640; + _klayman->getSurface()->getClipRect().y2 = 480; + + loadDataResource(0x00144822); + _klayman->setSoundFlag(true); + +} + +void Scene2205::update() { + Scene::update(); + + if (!_isLightOn && getGlobalVar(0x4D080E54)) { + _palette->addPalette(0x0008028D, 0, 256, 0); + _background->load(0x0008028D); + _ssLightSwitch->setFileHashes(0x2D339030, 0x2D309030); + _ssDoorFrame->sendMessage(0x2000, 0, this); + ((Mouse433*)_mouseCursor)->load(0x80289008); + ((Mouse433*)_mouseCursor)->updateCursor(); + _isLightOn = true; + } else if (_isLightOn && !getGlobalVar(0x4D080E54)) { + _palette->addPalette(0xD00A028D, 0, 256, 0); + _background->load(0xD00A028D); + _ssLightSwitch->setFileHashes(0x2D339030, 0xDAC86E84); + _ssDoorFrame->sendMessage(0x2000, 0, this); + ((Mouse433*)_mouseCursor)->load(0xA0289D08); + ((Mouse433*)_mouseCursor)->updateCursor(); + _isKlaymanInLight = true; + if (_klayman->getX() > 85) { + _palette->addPalette(0x68033B1C, 0, 65, 0); + _isKlaymanInLight = false; + } + _isLightOn = false; + } + + if (!getGlobalVar(0x4D080E54)) { + if (_isKlaymanInLight && _klayman->getX() > 85) { + ((Palette2*)_palette)->addPalette(0x68033B1C, 0, 65, 0); + ((Palette2*)_palette)->startFadeToPalette(12); + _isKlaymanInLight = false; + } else if (!_isKlaymanInLight && _klayman->getX() <= 85) { + ((Palette2*)_palette)->addPalette(0xD00A028D, 0, 65, 0); + ((Palette2*)_palette)->startFadeToPalette(12); + _isKlaymanInLight = true; + } + } + +} + +uint32 Scene2205::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { + Scene::handleMessage(messageNum, param, sender); + switch (messageNum) { + case 0x100D: + if (param.asInteger() == 0x6449569A) { + setMessageList(0x004B0690); + } else if (param.asInteger() == 0x2841369C) { + setMessageList(0x004B0630); + } else if (param.asInteger() == 0x402064D8) { + _klayman->sendEntityMessage(0x1014, _ssLightSwitch, this); + } + break; + case 0x480B: + setGlobalVar(0x4D080E54, getGlobalVar(0x4D080E54) ? 0 : 1); + break; + } + return 0; +} + } // End of namespace Neverhood diff --git a/engines/neverhood/module2200.h b/engines/neverhood/module2200.h index 6a0634f600..c79edb44d6 100644 --- a/engines/neverhood/module2200.h +++ b/engines/neverhood/module2200.h @@ -26,6 +26,7 @@ #include "neverhood/neverhood.h" #include "neverhood/module.h" #include "neverhood/scene.h" +#include "neverhood/module1000.h" namespace Neverhood { @@ -284,6 +285,25 @@ protected: uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender); }; +class SsScene2205DoorFrame : public StaticSprite { +public: + SsScene2205DoorFrame(NeverhoodEngine *vm); +protected: + uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender); +}; + +class Scene2205 : public Scene { +public: + Scene2205(NeverhoodEngine *vm, Module *parentModule, int which); +protected: + Class426 *_ssLightSwitch; + Sprite *_ssDoorFrame; + bool _isKlaymanInLight; + bool _isLightOn; + void update(); + uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender); +}; + } // End of namespace Neverhood #endif /* NEVERHOOD_MODULE2200_H */ diff --git a/engines/neverhood/mouse.h b/engines/neverhood/mouse.h index 4f27cb4e95..65dcb27856 100644 --- a/engines/neverhood/mouse.h +++ b/engines/neverhood/mouse.h @@ -34,19 +34,20 @@ class Mouse433 : public StaticSprite { public: Mouse433(NeverhoodEngine *vm, uint32 fileHash, NRect *mouseRect); void load(uint32 fileHash); + void updateCursor(); protected: MouseCursorResource _mouseCursorResource; int _frameNum; NRect _mouseRect; void update(); uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender); - void updateCursor(); }; class Mouse435 : public StaticSprite { public: Mouse435(NeverhoodEngine *vm, uint32 fileHash, int16 x1, int16 x2); void load(uint32 fileHash); + void updateCursor(); protected: MouseCursorResource _mouseCursorResource; int _frameNum; @@ -54,20 +55,19 @@ protected: int16 _x2; void update(); uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender); - void updateCursor(); }; class NavigationMouse : public StaticSprite { public: NavigationMouse(NeverhoodEngine *vm, uint32 fileHash, int type); void load(uint32 fileHash); + void updateCursor(); protected: MouseCursorResource _mouseCursorResource; int _frameNum; int _type; void update(); uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender); - void updateCursor(); }; } // End of namespace Neverhood |