aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/neverhood/gamemodule.cpp2
-rw-r--r--engines/neverhood/klayman.cpp143
-rw-r--r--engines/neverhood/klayman.h13
-rw-r--r--engines/neverhood/module2200.cpp343
-rw-r--r--engines/neverhood/module2200.h49
5 files changed, 548 insertions, 2 deletions
diff --git a/engines/neverhood/gamemodule.cpp b/engines/neverhood/gamemodule.cpp
index fd603a8972..6450f5a42a 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 = 4;
+ _vm->gameState().sceneNum = 5;
createModule2200(-1);
#endif
}
diff --git a/engines/neverhood/klayman.cpp b/engines/neverhood/klayman.cpp
index 404cce5e76..97fdd5a0ad 100644
--- a/engines/neverhood/klayman.cpp
+++ b/engines/neverhood/klayman.cpp
@@ -3658,4 +3658,147 @@ void KmScene2205::sub423980() {
setCallback1(AnimationCallback(&Klayman::sub41FB30));
}
+KmScene2206::KmScene2206(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y)
+ : Klayman(vm, parentScene, x, y, 1000, 1000) {
+
+ // TODO Sound1ChList_addSoundResource(0x80101800, 0xD3B02847);
+}
+
+KmScene2206::~KmScene2206() {
+ // TODO Sound1ChList_sub_407AF0(0x80101800);
+}
+
+void KmScene2206::xUpdate() {
+ setGlobalVar(0x18288913, _frameIndex);
+}
+
+uint32 KmScene2206::xHandleMessage(int messageNum, const MessageParam &param) {
+ switch (messageNum) {
+ case 0x4001:
+ case 0x4800:
+ sub41C930(param.asPoint().x, false);
+ break;
+ case 0x4004:
+ setCallback2(AnimationCallback(&Klayman::sub41FC80));
+ break;
+ case 0x4803:
+ setCallback2(AnimationCallback(&KmScene2206::sub482490));
+ break;
+ case 0x4804:
+ if (param.asInteger() != 0) {
+ _x4 = param.asInteger();
+ setCallback2(AnimationCallback(&KmScene2206::sub482530));
+ } else {
+ setCallback2(AnimationCallback(&Klayman::sub41FC40));
+ }
+ break;
+ case 0x4812:
+ 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 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 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 0x4837:
+ // TODO sub41CE70();
+ break;
+ case 0x483F:
+ sub41CD00(param.asInteger());
+ break;
+ case 0x4840:
+ sub41CD70(param.asInteger());
+ break;
+ }
+ return 0;
+}
+
+void KmScene2206::spriteUpdate482450() {
+ _yDelta++;
+ _y += _yDelta;
+ if (_y > 600) {
+ sendMessage(0x1019, 0, this);
+ }
+}
+
+void KmScene2206::sub482490() {
+ if (!sub41CF10(AnimationCallback(&KmScene2206::sub482490))) {
+ _status2 = 1;
+ _parentScene->sendMessage(0x4803, 0, this);
+ _flagE5 = false;
+ _yDelta = 0;
+ setFileHash(0x5420E254, 0, -1);
+ SetUpdateHandler(&Klayman::update);
+ SetMessageHandler(&Klayman::handleMessage41D360);
+ SetSpriteCallback(&KmScene2206::spriteUpdate482450);
+ // TODO Sound1ChList_playLooping(0xD3B02847);
+ }
+}
+
+void KmScene2206::sub482530() {
+ int16 frameIndex = 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 d9d63b1011..3cb5e3803c 100644
--- a/engines/neverhood/klayman.h
+++ b/engines/neverhood/klayman.h
@@ -396,6 +396,19 @@ protected:
uint32 xHandleMessage(int messageNum, const MessageParam &param);
};
+class KmScene2206 : public Klayman {
+public:
+ KmScene2206(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y);
+ ~KmScene2206();
+protected:
+ int16 _yDelta;
+ void xUpdate();
+ uint32 xHandleMessage(int messageNum, const MessageParam &param);
+ void spriteUpdate482450();
+ void sub482490();
+ void sub482530();
+};
+
} // End of namespace Neverhood
#endif /* NEVERHOOD_KLAYMAN_H */
diff --git a/engines/neverhood/module2200.cpp b/engines/neverhood/module2200.cpp
index e7e025750f..bec20fa0d1 100644
--- a/engines/neverhood/module2200.cpp
+++ b/engines/neverhood/module2200.cpp
@@ -221,11 +221,15 @@ 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);
+ _childObject = new Scene2205(_vm, this, which);
SetUpdateHandler(&Module2200::updateScene2205);
}
void Module2200::createScene2206(int which) {
+ _vm->gameState().sceneNum = 5;
+ // TODO Music18hList_stop(0x601C908C, 0, 2);
+ _childObject = new Scene2206(_vm, this, which);
+ SetUpdateHandler(&Module2200::updateScene2206);
}
void Module2200::createScene2207(int which) {
@@ -429,6 +433,25 @@ void Module2200::updateScene2205() {
}
void Module2200::updateScene2206() {
+ _childObject->handleUpdate();
+ if (_done) {
+ _done = false;
+ delete _childObject;
+ _childObject = NULL;
+ if (_field20 == 1) {
+ createScene2247(0);
+ _childObject->handleUpdate();
+ } else if (_field20 == 2) {
+ createScene2207(0);
+ _childObject->handleUpdate();
+ } else if (_field20 == 3) {
+ createScene2209(0);
+ _childObject->handleUpdate();
+ } else {
+ createScene2205(1);
+ _childObject->handleUpdate();
+ }
+ }
}
void Module2200::updateScene2207() {
@@ -1567,4 +1590,322 @@ uint32 Scene2205::handleMessage(int messageNum, const MessageParam &param, Entit
return 0;
}
+static const int16 kScene2206XPositions[] = {
+ 384,
+ 480,
+ 572
+};
+
+static const uint32 kScene2206MessageIds1[] = {
+ 0x004B8998,
+ 0x004B89B8,
+ 0x004B89D8
+};
+
+static const uint32 kScene2206MessageIds2[] = {
+ 0x004B89F8,
+ 0x004B8A20,
+ 0x004B8A48
+};
+
+static const int16 kClass603XDeltas1[] = {
+ -24, -28, -18, 6, 9, -8
+};
+
+static const int16 kClass603XDeltas2[] = {
+ -8, 7, 11, 26, 13, 14
+};
+
+Class603::Class603(NeverhoodEngine *vm, uint32 fileHash)
+ : StaticSprite(vm, fileHash, 200), _soundResource(vm) {
+
+ if (getGlobalVar(0x18890C91))
+ _x -= 63;
+ SetUpdateHandler(&Class603::update);
+ SetMessageHandler(&Class603::handleMessage);
+ SetSpriteCallback(NULL);
+}
+
+void Class603::update() {
+ handleSpriteUpdate();
+ StaticSprite::update();
+}
+
+uint32 Class603::handleMessage(int messageNum, const MessageParam &param, Entity *sender) {
+ uint32 messageResult = Sprite::handleMessage(messageNum, param, sender);
+ switch (messageNum) {
+ case 0x4808:
+ _index = 0;
+ SetMessageHandler(NULL);
+ SetSpriteCallback(&Class603::spriteUpdate481E60);
+ _soundResource.play(0x032746E0);
+ break;
+ case 0x4809:
+ _index = 0;
+ SetMessageHandler(NULL);
+ SetSpriteCallback(&Class603::spriteUpdate481E90);
+ _soundResource.play(0x002642C0);
+ break;
+ }
+ return messageResult;
+}
+
+void Class603::spriteUpdate481E60() {
+ if (_index < 6) {
+ _x += kClass603XDeltas1[_index];
+ _index++;
+ } else {
+ SetMessageHandler(&Class603::handleMessage);
+ SetSpriteCallback(NULL);
+ }
+}
+
+void Class603::spriteUpdate481E90() {
+ if (_index < 6) {
+ _x += kClass603XDeltas2[_index];
+ _index++;
+ } else {
+ SetMessageHandler(&Class603::handleMessage);
+ SetSpriteCallback(NULL);
+ }
+}
+
+Class604::Class604(NeverhoodEngine *vm, uint32 fileHash)
+ : StaticSprite(vm, fileHash, 50) {
+
+ SetUpdateHandler(&Class604::update);
+ SetMessageHandler(&Class604::handleMessage);
+ SetSpriteCallback(NULL);
+}
+
+void Class604::update() {
+ handleSpriteUpdate();
+ StaticSprite::update();
+}
+
+uint32 Class604::handleMessage(int messageNum, const MessageParam &param, Entity *sender) {
+ uint32 messageResult = Sprite::handleMessage(messageNum, param, sender);
+ switch (messageNum) {
+ case 0x4803:
+ SetMessageHandler(NULL);
+ SetSpriteCallback(&Class604::spriteUpdate482020);
+ _yDelta = 0;
+ break;
+ }
+ return messageResult;
+}
+
+void Class604::spriteUpdate482020() {
+ _yDelta++;
+ _y += _yDelta;
+}
+
+Class607::Class607(NeverhoodEngine *vm, Scene *parentScene, int surfacePriority, uint32 fileHash)
+ : StaticSprite(vm, fileHash, surfacePriority), _parentScene(parentScene) {
+
+ if (getGlobalVar(0x45080C38)) {
+ _surface->setVisible(false);
+ SetMessageHandler(NULL);
+ } else {
+ SetMessageHandler(&Class607::handleMessage);
+ }
+ _deltaRect = _drawRect;
+ processDelta();
+}
+
+uint32 Class607::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:
+ setGlobalVar(0x45080C38, 1);
+ _surface->setVisible(false);
+ SetMessageHandler(NULL);
+ break;
+ }
+ return messageResult;
+}
+
+Scene2206::Scene2206(NeverhoodEngine *vm, Module *parentModule, int which)
+ : Scene(vm, parentModule, true), _soundResource(vm) {
+
+ uint32 fileHash;
+ Palette2 *palette2;
+
+ SetUpdateHandler(&Scene::update);
+ SetMessageHandler(&Scene2206::handleMessage);
+ _surfaceFlag = true;
+
+ if (getGlobalVar(0x4D080E54)) {
+ fileHash = 0x41983216;
+ _sprite1 = addSprite(new StaticSprite(_vm, 0x2201266A, 100));
+ _sprite2 = addSprite(new StaticSprite(_vm, 0x3406A333, 300));
+ _sprite3 = addSprite(new StaticSprite(_vm, 0x24A223A2, 100));
+ _sprite4 = addSprite(new Class603(_vm, 0x26133023));
+ _sprite4->getSurface()->getClipRect().x1 = _sprite2->getSurface()->getDrawRect().x;
+ _sprite4->getSurface()->getClipRect().y1 = 0;
+ _sprite4->getSurface()->getClipRect().x2 = 640;
+ _sprite4->getSurface()->getClipRect().y2 = 480;
+ setRectList(0x004B8AF8);
+ _sprite5 = addSprite(new SsCommonButtonSprite(_vm, this, 0x0E038022, 100, 0));
+ _mouseCursor = addSprite(new Mouse433(_vm, 0x83212411, NULL));
+ _class607 = addSprite(new Class607(_vm, this, 1100, /*464, 433, */0x5E00E262));
+ _class604 = addSprite(new Class604(_vm, 0x085E25E0));
+ } else {
+ fileHash = 0xE0102A45;
+ _sprite1 = addSprite(new StaticSprite(_vm, 0x1C1106B8, 100));
+ _sprite2 = addSprite(new StaticSprite(_vm, 0x020462E0, 300));
+ _sprite3 = addSprite(new StaticSprite(_vm, 0x900626A2, 100));
+ _sprite4 = addSprite(new Class603(_vm, 0x544822A8));
+ _sprite4->getSurface()->getClipRect().x1 = _sprite2->getSurface()->getDrawRect().x;
+ _sprite4->getSurface()->getClipRect().y1 = 0;
+ _sprite4->getSurface()->getClipRect().x2 = 640;
+ _sprite4->getSurface()->getClipRect().y2 = 480;
+ setRectList(0x004B8B58);
+ _sprite5 = addSprite(new SsCommonButtonSprite(_vm, this, 0x16882608, 100, 0));
+ _mouseCursor = addSprite(new Mouse433(_vm, 0x02A41E09, NULL));
+ _class607 = addSprite(new Class607(_vm, this, 1100, /*464, 433, */0x52032563));
+ _class604 = addSprite(new Class604(_vm, 0x317831A0));
+ }
+
+ _class604->getSurface()->getClipRect().x1 = _sprite2->getSurface()->getDrawRect().x;
+ _class604->getSurface()->getClipRect().y1 = 0;
+ _class604->getSurface()->getClipRect().x2 = _sprite3->getSurface()->getDrawRect().x + _sprite3->getSurface()->getDrawRect().width;
+ _class604->getSurface()->getClipRect().y2 = _sprite1->getSurface()->getDrawRect().y + _sprite1->getSurface()->getDrawRect().height;
+
+ _background = addBackground(new DirtyBackground(_vm, fileHash, 0, 0));
+
+ palette2 = new Palette2(_vm, fileHash);
+ _palette = palette2;
+ _palette->usePalette();
+ addEntity(palette2);
+
+ palette2->addPalette(fileHash, 0, 256, 0);
+
+ if (!getGlobalVar(0x4D080E54)) {
+ _palette->addPalette(0x0263D144, 0, 65, 0);
+ }
+
+ _vm->_collisionMan->addSprite(_class607);
+
+ if (which < 0) {
+ _klayman = new KmScene2206(_vm, this, 200, 430);
+ setMessageList(0x004B88A8);
+ } else if (which == 1) {
+ _klayman = new KmScene2206(_vm, this, 640, 430);
+ setMessageList(0x004B88B8);
+ } else if (which == 2) {
+ _klayman = new KmScene2206(_vm, this, 205, 396);
+ setMessageList(0x004B88C8);
+ _palette->addPalette(getGlobalVar(0x4D080E54) ? 0xB103B604 : 0x0263D144, 0, 65, 0);
+ sub4819D0();
+ _soundResource.play(0x53B8284A);
+ } else if (which == 3) {
+ _klayman = new KmScene2206(_vm, this, kScene2206XPositions[getGlobalVar(0x48A68852)], 430);
+ if (getGlobalVar(0xC0418A02))
+ _klayman->setDoDeltaX(1);
+ setMessageList(0x004B8A70);
+ } else {
+ _klayman = new KmScene2206(_vm, this, 0, 430);
+ setMessageList(0x004B88B0);
+ }
+ addSprite(_klayman);
+
+ _klayman->setSoundFlag(true);
+ _klayman->setKlaymanTable2();
+
+}
+
+Scene2206::~Scene2206() {
+ setGlobalVar(0xC0418A02, _klayman->isDoDeltaX() ? 1 : 0);
+}
+
+uint32 Scene2206::handleMessage(int messageNum, const MessageParam &param, Entity *sender) {
+ uint32 messageResult = Scene::handleMessage(messageNum, param, sender);
+ switch (messageNum) {
+ case 0x100D:
+ if (param.asInteger() == 0x800C6694) {
+ sub481B00();
+ } else if (param.asInteger() == 0x402064D8) {
+ _klayman->sendEntityMessage(0x1014, _sprite5, this);
+ } else if (param.asInteger() == 0x11C40840) {
+ if (getGlobalVar(0x18890C91))
+ setMessageList(0x004B8948);
+ else
+ setMessageList(0x004B8970);
+ }
+ break;
+ case 0x4803:
+ _class604->sendMessage(0x4803, 0, this);
+ break;
+ case 0x480B:
+ if (sender == _sprite5) {
+ setGlobalVar(0x18890C91, getGlobalVar(0x18890C91) ? 0 : 1);
+ if (getGlobalVar(0x18890C91))
+ _sprite4->sendMessage(0x4808, 0, this);
+ else
+ _sprite4->sendMessage(0x4809, 0, this);
+ }
+ break;
+ case 0x4826:
+ _klayman->sendEntityMessage(0x1014, _class607, this);
+ setMessageList(0x004B8988);
+ break;
+ case 0x482A:
+ sub4819D0();
+ break;
+ case 0x482B:
+ sub481950();
+ break;
+ }
+ return messageResult;
+}
+
+void Scene2206::sub481950() {
+ if (getGlobalVar(0x4D080E54)) {
+ ((Palette2*)_palette)->addPalette(0x41983216, 0, 65, 0);
+ ((Palette2*)_palette)->startFadeToPalette(12);
+ }
+ setSurfacePriority(_sprite1->getSurface(), 100);
+ setSurfacePriority(_sprite2->getSurface(), 300);
+ setSurfacePriority(_sprite3->getSurface(), 100);
+ setSurfacePriority(_sprite4->getSurface(), 200);
+ _klayman->getSurface()->getClipRect().x1 = 0;
+ _klayman->getSurface()->getClipRect().y1 = 0;
+ _klayman->getSurface()->getClipRect().x2 = 640;
+ _klayman->getSurface()->getClipRect().y2 = 480;
+}
+
+void Scene2206::sub4819D0() {
+ if (!getGlobalVar(0x4D080E54)) {
+ ((Palette2*)_palette)->addPalette(0xB103B604, 0, 65, 0);
+ ((Palette2*)_palette)->startFadeToPalette(12);
+ }
+ setSurfacePriority(_sprite1->getSurface(), 1100);
+ setSurfacePriority(_sprite2->getSurface(), 1300);
+ setSurfacePriority(_sprite3->getSurface(), 1100);
+ setSurfacePriority(_sprite4->getSurface(), 1200);
+ _klayman->getSurface()->getClipRect().x1 = _sprite2->getSurface()->getDrawRect().x;
+ _klayman->getSurface()->getClipRect().y1 = 0;
+ _klayman->getSurface()->getClipRect().x2 = _sprite3->getSurface()->getDrawRect().x + _sprite3->getSurface()->getDrawRect().width;
+ _klayman->getSurface()->getClipRect().y2 = _sprite1->getSurface()->getDrawRect().y + _sprite1->getSurface()->getDrawRect().height;
+}
+
+void Scene2206::sub481B00() {
+ setGlobalVar(0x48A68852, (_mouseClickPos.x - 354) / 96);
+ if (getGlobalVar(0x48A68852) > 2)
+ setGlobalVar(0x48A68852, 2);
+ setGlobalVar(0x49C40058, (_mouseClickPos.y - 183) / 7);
+ setGlobalVar(0xC8C28808, calcHash("stLineagex"));
+ setGlobalVar(0x4CE79018, 0);
+ if (ABS(kScene2206XPositions[getGlobalVar(0x48A68852)] - _klayman->getX()) >= 144) {
+ setMessageList2(kScene2206MessageIds1[getGlobalVar(0x48A68852)]);
+ } else {
+ setMessageList2(kScene2206MessageIds2[getGlobalVar(0x48A68852)]);
+ }
+}
+
} // End of namespace Neverhood
diff --git a/engines/neverhood/module2200.h b/engines/neverhood/module2200.h
index c79edb44d6..ef56c3f0ac 100644
--- a/engines/neverhood/module2200.h
+++ b/engines/neverhood/module2200.h
@@ -304,6 +304,55 @@ protected:
uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
};
+class Class603 : public StaticSprite {
+public:
+ Class603(NeverhoodEngine *vm, uint32 fileHash);
+protected:
+ int _index;
+ SoundResource _soundResource;
+ void update();
+ uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
+ void spriteUpdate481E60();
+ void spriteUpdate481E90();
+};
+
+class Class604 : public StaticSprite {
+public:
+ Class604(NeverhoodEngine *vm, uint32 fileHash);
+protected:
+ int16 _yDelta;
+ void update();
+ uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
+ void spriteUpdate482020();
+};
+
+class Class607 : public StaticSprite {
+public:
+ Class607(NeverhoodEngine *vm, Scene *parentScene, int surfacePriority, uint32 fileHash);
+protected:
+ Scene *_parentScene;
+ uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
+};
+
+class Scene2206 : public Scene {
+public:
+ Scene2206(NeverhoodEngine *vm, Module *parentModule, int which);
+ ~Scene2206();
+protected:
+ Sprite *_sprite1;
+ Sprite *_sprite2;
+ Sprite *_sprite3;
+ Sprite *_sprite4;
+ Sprite *_sprite5;
+ Sprite *_class604;
+ Sprite *_class607;
+ SoundResource _soundResource;
+ uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
+ void sub481950();
+ void sub4819D0();
+ void sub481B00();
+};
+
} // End of namespace Neverhood
#endif /* NEVERHOOD_MODULE2200_H */