aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjohndoe1232011-07-27 18:02:30 +0000
committerWillem Jan Palenstijn2013-05-08 20:39:34 +0200
commitd7dd4b43563b3d0ad5b16ff1fb384ab1382b3848 (patch)
treebd999ffbf43b6b5ec85258f26b7e3175dd40f716
parentbfd71cff6e73c0be6b2d66f7f71921094f42ca09 (diff)
downloadscummvm-rg350-d7dd4b43563b3d0ad5b16ff1fb384ab1382b3848.tar.gz
scummvm-rg350-d7dd4b43563b3d0ad5b16ff1fb384ab1382b3848.tar.bz2
scummvm-rg350-d7dd4b43563b3d0ad5b16ff1fb384ab1382b3848.zip
NEVERHOOD: Implement Scene1403, Scene1404 and Scene1405 (memory minigame)
- Move GameModule::startup call into engine instead of the game module constructor - Reduce debug output
-rw-r--r--engines/neverhood/entity.h4
-rw-r--r--engines/neverhood/gamemodule.cpp103
-rw-r--r--engines/neverhood/gamemodule.h3
-rw-r--r--engines/neverhood/gamevars.cpp33
-rw-r--r--engines/neverhood/klayman.cpp355
-rw-r--r--engines/neverhood/klayman.h26
-rw-r--r--engines/neverhood/module1400.cpp448
-rw-r--r--engines/neverhood/module1400.h66
-rw-r--r--engines/neverhood/neverhood.cpp8
-rw-r--r--engines/neverhood/neverhood.h1
-rw-r--r--engines/neverhood/scene.cpp2
-rw-r--r--engines/neverhood/sprite.h2
12 files changed, 977 insertions, 74 deletions
diff --git a/engines/neverhood/entity.h b/engines/neverhood/entity.h
index 18c6b7e7b9..e49aa94e08 100644
--- a/engines/neverhood/entity.h
+++ b/engines/neverhood/entity.h
@@ -74,8 +74,8 @@ protected:
// TODO: Disable heavy debug stuff in release mode
-#define SetUpdateHandler(handler) _updateHandlerCb = static_cast <void (Entity::*)(void)> (handler); debug("SetUpdateHandler(" #handler ")"); _updateHandlerCbName = #handler
-#define SetMessageHandler(handler) _messageHandlerCb = static_cast <uint32 (Entity::*)(int messageNum, const MessageParam &param, Entity *sender)> (handler); debug("SetMessageHandler(" #handler ")"); _messageHandlerCbName = #handler
+#define SetUpdateHandler(handler) _updateHandlerCb = static_cast <void (Entity::*)(void)> (handler); debug(2, "SetUpdateHandler(" #handler ")"); _updateHandlerCbName = #handler
+#define SetMessageHandler(handler) _messageHandlerCb = static_cast <uint32 (Entity::*)(int messageNum, const MessageParam &param, Entity *sender)> (handler); debug(2, "SetMessageHandler(" #handler ")"); _messageHandlerCbName = #handler
class Entity {
public:
diff --git a/engines/neverhood/gamemodule.cpp b/engines/neverhood/gamemodule.cpp
index 02ae2a7cac..d4b1e7bfd5 100644
--- a/engines/neverhood/gamemodule.cpp
+++ b/engines/neverhood/gamemodule.cpp
@@ -44,7 +44,7 @@ GameModule::GameModule(NeverhoodEngine *vm)
SetMessageHandler(&GameModule::handleMessage);
- startup();
+ //startup();
}
@@ -83,6 +83,105 @@ void GameModule::handleMouseDown(int16 x, int16 y) {
}
}
+void GameModule::initScene1405Vars() {
+
+ // TODO: Give better names
+
+ byte array44[3];
+ byte array3C[10];
+ byte array30[48];
+ uint32 index3 = 48;
+ uint32 index2 = 9;
+ uint32 index1 = 2;
+ uint32 rndIndex;
+
+ // Exit if it's already initialized
+ if (getSubVar(0x40050052, 0xC8606803))
+ return;
+
+ for (uint32 i = 0; i < 3; i++)
+ setSubVar(0x61084036, i, 1);
+
+ for (byte i = 0; i < 3; i++)
+ array44[i] = i;
+
+ for (byte i = 0; i < 10; i++)
+ array3C[i] = i;
+
+ for (byte i = 0; i < 48; i++)
+ array30[i] = i;
+
+ rndIndex = _vm->_rnd->getRandomNumber(3 - 1);
+
+ setSubVar(0x13100631, array44[rndIndex], 5);
+
+ for (byte i = 5; i < 9; i++)
+ array3C[i] = array3C[i + 1];
+
+ while (rndIndex < 2) {
+ array44[rndIndex] = array44[rndIndex + 1];
+ rndIndex++;
+ }
+
+ for (int i = 0; i < 2; i++) {
+ uint32 rndIndex1 = _vm->_rnd->getRandomNumber(index2 - 1); // si
+ uint32 rndIndex2 = _vm->_rnd->getRandomNumber(index1 - 1); // di
+ setSubVar(0x13100631, array44[rndIndex2], array3C[rndIndex1]);
+ index2--;
+ while (rndIndex1 < index2) {
+ array3C[rndIndex1] = array3C[rndIndex1 + 1];
+ rndIndex1++;
+ }
+ index1--;
+ while (rndIndex2 < index1) {
+ array44[rndIndex2] = array44[rndIndex2 + 1];
+ rndIndex2++;
+ }
+ }
+
+ for (uint32 i = 0; i < 3; i++) {
+ uint32 rndValue = _vm->_rnd->getRandomNumber(4 - 1) * 2 + 2;
+ uint32 index4 = 0;
+ setSubVar(0x7500993A, i, rndValue);
+ while (index4 < rndValue) {
+ uint32 rndIndex3 = _vm->_rnd->getRandomNumber(index3 - 1);
+ setSubVar(0x0C65F80B, array30[rndIndex3], getSubVar(0x13100631, i));
+ index3--;
+ while (rndIndex3 < index3) {
+ array30[rndIndex3] = array30[rndIndex3 + 1];
+ rndIndex3++;
+ }
+ index4++;
+ }
+ }
+
+ uint32 index5 = 0;
+ while (index3 != 0) {
+ uint32 rndIndex4 = _vm->_rnd->getRandomNumber(index3 - 1);
+ index1 = array3C[index5];
+ setSubVar(0x0C65F80B, array30[rndIndex4], index1);
+ index3--;
+ while (rndIndex4 < index3) {
+ array30[rndIndex4] = array30[rndIndex4 + 1];
+ rndIndex4++;
+ }
+ uint32 rndIndex5 = _vm->_rnd->getRandomNumber(index3 - 1);
+ setSubVar(0x0C65F80B, array30[rndIndex5], index1);
+ index3--;
+ while (rndIndex5 < index3) {
+ array30[rndIndex5] = array30[rndIndex5 + 1];
+ rndIndex5++;
+ }
+ index5++;
+ if (index5 >= index2)
+ index5 = 0;
+
+ }
+
+ setSubVar(0x40050052, 0xC8606803, 1);
+
+}
+
uint32 GameModule::handleMessage(int messageNum, const MessageParam &param, Entity *sender) {
uint32 messageResult = Module::handleMessage(messageNum, param, sender);
switch (messageNum) {
@@ -114,7 +213,7 @@ void GameModule::startup() {
// createModule1500(0); // Logos and intro video //Real
// createModule1000(-1);
// createModule2300(2);
- _vm->gameState().sceneNum = 6;
+ _vm->gameState().sceneNum = 4;
//createModule1200(-1);
//createModule1800(-1);
//createModule1700(-1);
diff --git a/engines/neverhood/gamemodule.h b/engines/neverhood/gamemodule.h
index 344a78ff60..d93a7994a7 100644
--- a/engines/neverhood/gamemodule.h
+++ b/engines/neverhood/gamemodule.h
@@ -34,8 +34,10 @@ class GameModule : public Module {
public:
GameModule(NeverhoodEngine *vm);
virtual ~GameModule();
+ void startup();
void handleMouseMove(int16 x, int16 y);
void handleMouseDown(int16 x, int16 y);
+ void initScene1405Vars();
protected:
Entity *_prevChildObject;
bool _someFlag1;
@@ -48,7 +50,6 @@ protected:
ResourceTable _resourceTable4;
*/
uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
- void startup();
void createModule1000(int which);
void updateModule1000();
void createModule1200(int which);
diff --git a/engines/neverhood/gamevars.cpp b/engines/neverhood/gamevars.cpp
index caf79b2ad9..e0cae80105 100644
--- a/engines/neverhood/gamevars.cpp
+++ b/engines/neverhood/gamevars.cpp
@@ -32,18 +32,18 @@ GameVars::~GameVars() {
}
uint32 GameVars::getGlobalVar(uint32 nameHash) {
- debug("GameVars::getGlobalVar(%08X)", nameHash);
+ //debug("GameVars::getGlobalVar(%08X)", nameHash);
int16 varIndex = findSubVarIndex(0, nameHash);
return varIndex != -1 ? _vars[varIndex].value : 0;
}
void GameVars::setGlobalVar(uint32 nameHash, uint32 value) {
- debug("GameVars::setGlobalVar(%08X, %d)", nameHash, value);
+ //debug("GameVars::setGlobalVar(%08X, %d)", nameHash, value);
_vars[getSubVarIndex(0, nameHash)].value = value;
}
uint32 GameVars::getSubVar(uint32 nameHash, uint32 subNameHash) {
- debug("GameVars::getSubVar(%08X, %08X)", nameHash, subNameHash);
+ //debug("GameVars::getSubVar(%08X, %08X)", nameHash, subNameHash);
uint32 value = 0;
int16 varIndex = findSubVarIndex(0, nameHash);
if (varIndex != -1) {
@@ -56,21 +56,17 @@ uint32 GameVars::getSubVar(uint32 nameHash, uint32 subNameHash) {
}
void GameVars::setSubVar(uint32 nameHash, uint32 subNameHash, uint32 value) {
- debug("GameVars::setSubVar(%08X, %08X, %d)", nameHash, subNameHash, value);
-
+ //debug("GameVars::setSubVar(%08X, %08X, %d)", nameHash, subNameHash, value);
int16 varIndex = getSubVarIndex(0, nameHash);
- debug(" varIndex = %d", varIndex);
-
+ //debug(" varIndex = %d", varIndex);
int16 subVarIndex = getSubVarIndex(varIndex, subNameHash);
- debug(" subVarIndex = %d", subVarIndex);
-
+ //debug(" subVarIndex = %d", subVarIndex);
_vars[subVarIndex].value = value;
-
//_vars[getSubVarIndex(getSubVarIndex(0, nameHash), subNameHash)].value = value;
}
int16 GameVars::addVar(uint32 nameHash, uint32 value) {
- debug("GameVars::addVar(%08X, %d)", nameHash, value);
+ //debug("GameVars::addVar(%08X, %d)", nameHash, value);
GameVar gameVar;
gameVar.nameHash = nameHash;
gameVar.value = value;
@@ -81,7 +77,7 @@ int16 GameVars::addVar(uint32 nameHash, uint32 value) {
}
int16 GameVars::findSubVarIndex(int16 varIndex, uint32 subNameHash) {
- debug("GameVars::findSubVarIndex(%d, %08X)", varIndex, subNameHash);
+ //debug("GameVars::findSubVarIndex(%d, %08X)", varIndex, subNameHash);
for (int16 nextIndex = _vars[varIndex].firstIndex; nextIndex != -1; nextIndex = _vars[nextIndex].nextIndex) {
if (_vars[nextIndex].nameHash == subNameHash)
return nextIndex;
@@ -90,18 +86,19 @@ int16 GameVars::findSubVarIndex(int16 varIndex, uint32 subNameHash) {
}
int16 GameVars::addSubVar(int16 varIndex, uint32 subNameHash, uint32 value) {
- debug("GameVars::addSubVar(%d, %08X, %d)", varIndex, subNameHash, value);
+ //debug("GameVars::addSubVar(%d, %08X, %d)", varIndex, subNameHash, value);
int16 nextIndex = _vars[varIndex].firstIndex;
+ int16 subVarIndex;
if (nextIndex == -1) {
- _vars[varIndex].firstIndex = addVar(subNameHash, value);
- return _vars[varIndex].firstIndex;
+ subVarIndex = addVar(subNameHash, value);
+ _vars[varIndex].firstIndex = subVarIndex;
} else {
while (_vars[nextIndex].nextIndex != -1)
nextIndex = _vars[nextIndex].nextIndex;
- int16 index = addVar(subNameHash, value);
- _vars[nextIndex].nextIndex = index;
- return index;
+ subVarIndex = addVar(subNameHash, value);
+ _vars[nextIndex].nextIndex = subVarIndex;
}
+ return subVarIndex;
}
int16 GameVars::getSubVarIndex(int16 varIndex, uint32 subNameHash) {
diff --git a/engines/neverhood/klayman.cpp b/engines/neverhood/klayman.cpp
index b24e3eb6b4..3aaab36874 100644
--- a/engines/neverhood/klayman.cpp
+++ b/engines/neverhood/klayman.cpp
@@ -49,6 +49,12 @@ static const KlaymanTableItem klaymanTable3[] = {
};
#endif
+static const KlaymanTableItem klaymanTable4[] = {
+ {1, &Klayman::sub41FDA0},
+ {1, &Klayman::sub41FE60},
+ {1, &Klayman::sub41FEB0},
+};
+
// Klayman
Klayman::Klayman(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y, int surfacePriority, int objectPriority)
@@ -471,7 +477,7 @@ bool Klayman::sub41CF10(AnimationCb callback) {
}
void Klayman::sub41C7B0() {
- debug("Klayman::sub41C7B0()");
+ //debug("Klayman::sub41C7B0()");
if (_callback1Cb) {
AnimationCb cb = _callback1Cb;
_callback1Cb = NULL;
@@ -541,7 +547,7 @@ void Klayman::update41D0F0() {
}
uint32 Klayman::handleMessage41D360(int messageNum, const MessageParam &param, Entity *sender) {
- debug("Klayman::handleMessage41D360(%04X)", messageNum);
+ //debug("Klayman::handleMessage41D360(%04X)", messageNum);
Sprite::handleMessage(messageNum, param, sender);
uint32 messageResult = xHandleMessage(messageNum, param);
switch (messageNum) {
@@ -587,7 +593,7 @@ void Klayman::sub41FF00() {
}
uint32 Klayman::handleMessage41D480(int messageNum, const MessageParam &param, Entity *sender) {
- debug("Klayman::handleMessage41D480(%04X)", messageNum);
+ //debug("Klayman::handleMessage41D480(%04X)", messageNum);
uint32 messageResult = handleMessage41D360(messageNum, param, sender);
switch (messageNum) {
case 0x3002:
@@ -608,7 +614,7 @@ void Klayman::sub41FCF0() {
}
uint32 Klayman::handleMessage41F140(int messageNum, const MessageParam &param, Entity *sender) {
- debug("Klayman::handleMessage41F140(%04X)", messageNum);
+ //debug("Klayman::handleMessage41F140(%04X)", messageNum);
uint32 messageResult = handleMessage41D480(messageNum, param, sender);
switch (messageNum) {
case 0x100D:
@@ -624,7 +630,7 @@ uint32 Klayman::handleMessage41F140(int messageNum, const MessageParam &param, E
void Klayman::sub41C930(int16 x, bool flag) {
- debug("Klayman::sub41C930(%d, %d)", x, flag);
+ //debug("Klayman::sub41C930(%d, %d)", x, flag);
int16 xdiff = ABS(x - _x);
if (x == _x) {
_x4 = x;
@@ -675,7 +681,7 @@ void Klayman::sub4211B0() {
uint32 Klayman::handleMessage41E920(int messageNum, const MessageParam &param, Entity *sender) {
//ok
- debug("Klayman::handleMessage41E920(%04X)", messageNum);
+ //debug("Klayman::handleMessage41E920(%04X)", messageNum);
uint32 messageResult = handleMessage41D360(messageNum, param, sender);
switch (messageNum) {
case 0x100D:
@@ -704,7 +710,7 @@ bool Klayman::sub41CEB0(AnimationCb callback3) {
}
void Klayman::spriteUpdate41F250() {
- debug("Klayman::spriteUpdate41F250()");
+ //debug("Klayman::spriteUpdate41F250()");
int16 xdiff = _x4 - _x;
@@ -736,7 +742,7 @@ void Klayman::spriteUpdate41F250() {
}
void Klayman::spriteUpdate41F5F0() {
- debug("Klayman::spriteUpdate41F5F0()");
+ //debug("Klayman::spriteUpdate41F5F0()");
int16 xdiff = _x4 - _x;
@@ -801,7 +807,7 @@ void Klayman::sub41FBB0() {
}
uint32 Klayman::handleMessage41DD80(int messageNum, const MessageParam &param, Entity *sender) {
- debug("Klayman::handleMessage41DD80(%04X)", messageNum);
+ //debug("Klayman::handleMessage41DD80(%04X)", messageNum);
uint32 messageResult = handleMessage41D360(messageNum, param, sender);
switch (messageNum) {
case 0x100D:
@@ -832,7 +838,7 @@ uint32 Klayman::handleMessage41DD80(int messageNum, const MessageParam &param, E
}
void Klayman::sub41CD70(int16 x) {
- debug("Klayman::sub41CD70(%d)", x);
+ //debug("Klayman::sub41CD70(%d)", x);
if (x > _x) {
if (ABS(x - _x) <= 105) {
sub41CAC0(x);
@@ -868,7 +874,7 @@ void Klayman::sub41FB30() {
}
uint32 Klayman::handleMessage41EC70(int messageNum, const MessageParam &param, Entity *sender) {
- debug("Klayman::handleMessage41EC70(%04X)", messageNum);
+ //debug("Klayman::handleMessage41EC70(%04X)", messageNum);
uint32 messageResult = handleMessage41D480(messageNum, param, sender);
switch (messageNum) {
case 0x100D:
@@ -908,7 +914,7 @@ void Klayman::spriteUpdate41F300() {
}
uint32 Klayman::handleMessage41EB70(int messageNum, const MessageParam &param, Entity *sender) {
- debug("Klayman::handleMessage41EB70(%04X)", messageNum);
+ //debug("Klayman::handleMessage41EB70(%04X)", messageNum);
uint32 messageResult = handleMessage41D360(messageNum, param, sender);
switch (messageNum) {
case 0x100D:
@@ -1047,7 +1053,7 @@ void Klayman::sub41FF80() {
}
uint32 Klayman::handleMessage41D4C0(int messageNum, const MessageParam &param, Entity *sender) {
- debug("Klayman::handleMessage41D4C0(%04X)", messageNum);
+ //debug("Klayman::handleMessage41D4C0(%04X)", messageNum);
uint32 messageResult = handleMessage41D480(messageNum, param, sender);
switch (messageNum) {
case 0x100D:
@@ -1085,7 +1091,7 @@ void Klayman::sub420120() {
}
uint32 Klayman::handleMessage41DAD0(int messageNum, const MessageParam &param, Entity *sender) {
- debug("Klayman::handleMessage41DAD0(%04X)", messageNum);
+ //debug("Klayman::handleMessage41DAD0(%04X)", messageNum);
uint32 messageResult = handleMessage41D480(messageNum, param, sender);
switch (messageNum) {
case 0x100D:
@@ -1166,7 +1172,7 @@ void Klayman::sub41CC40(int16 x1, int16 x2) {
}
void Klayman::sub41CAC0(int16 x) {
- debug("Klayman::sub41CAC0(%d)", x);
+ //debug("Klayman::sub41CAC0(%d)", x);
int16 xdiff = ABS(x - _x);
if (x == _x) {
_x4 = x;
@@ -1256,7 +1262,7 @@ void Klayman::spriteUpdate41F780() {
}
uint32 Klayman::handleMessage41DF10(int messageNum, const MessageParam &param, Entity *sender) {
- debug("Klayman::handleMessage41DF10(%04X)", messageNum);
+ //debug("Klayman::handleMessage41DF10(%04X)", messageNum);
uint32 messageResult = handleMessage41D360(messageNum, param, sender);
switch (messageNum) {
case 0x100D:
@@ -1302,7 +1308,7 @@ void Klayman::sub4208F0() {
}
uint32 Klayman::handleMessage41EEF0(int messageNum, const MessageParam &param, Entity *sender) {
- debug("Klayman::handleMessage41EEF0(%04X)", messageNum);
+ //debug("Klayman::handleMessage41EEF0(%04X)", messageNum);
uint32 messageResult = handleMessage41D480(messageNum, param, sender);
switch (messageNum) {
case 0x100D:
@@ -1856,6 +1862,139 @@ void Klayman::sub420550() {
}
}
+void Klayman::sub420C50() {
+ if (!sub41CEB0(AnimationCallback(&Klayman::sub420C50))) {
+ _status2 = 0;
+ if (_flagF7) {
+ sub420D50();
+ } else {
+ _attachedSprite->sendMessage(0x482B, 0, this);
+ setFileHash(0x0C303040, 0, -1);
+ SetUpdateHandler(&Klayman::update);
+ SetSpriteCallback(&Klayman::spriteUpdate41F230);
+ SetMessageHandler(&Klayman::handleMessage41E210);
+ SetAnimationCallback3(&Klayman::sub420CD0);
+ _flagE5 = false;
+ }
+ }
+}
+
+void Klayman::sub420CD0() {
+ setFileHash(0x0D318140, 0, -1);
+ _attachedSprite->sendMessage(0x480F, 0, this);
+ SetAnimationCallback3(&Klayman::sub420D10);
+}
+
+void Klayman::sub420D10() {
+ setFileHash(0x4464A440, 0, -1);
+ SetUpdateHandler(&Klayman::update);
+ SetSpriteCallback(&Klayman::spriteUpdate41F230);
+ SetMessageHandler(&Klayman::handleMessage41D360);
+ _flagF7 = true;
+ _flagE5 = true;
+}
+
+void Klayman::sub420D50() {
+ setFileHash(0x09018068, 0, -1);
+ SetUpdateHandler(&Klayman::update);
+ SetSpriteCallback(&Klayman::spriteUpdate41F230);
+ SetMessageHandler(&Klayman::handleMessage41E210);
+ _attachedSprite->sendMessage(0x4807, 0, this);
+ SetAnimationCallback3(&Klayman::sub420DA0);
+ _flagE5 = false;
+}
+
+void Klayman::sub420DA0() {
+ setFileHash(0x0D318140, 0, -1);
+ _attachedSprite->sendMessage(0x480F, 0, this);
+ SetAnimationCallback3(&Klayman::sub420DE0);
+}
+
+void Klayman::sub420DE0() {
+ setFileHash(0x4464A440, 0, -1);
+ SetUpdateHandler(&Klayman::update);
+ SetSpriteCallback(&Klayman::spriteUpdate41F230);
+ SetMessageHandler(&Klayman::handleMessage41D360);
+ _flagF7 = true;
+ _flagE5 = true;
+}
+
+void Klayman::sub420E20() {
+ if (_flagF7) {
+ _status2 = 2;
+ setFileHash(0x09018068, 0, -1);
+ SetUpdateHandler(&Klayman::update);
+ SetSpriteCallback(&Klayman::spriteUpdate41F230);
+ SetMessageHandler(&Klayman::handleMessage41E210);
+ _attachedSprite->sendMessage(0x4807, 0, this);
+ SetAnimationCallback3(&Klayman::sub420E90);
+ _flagE5 = false;
+ _flagF7 = false;
+ } else {
+ sub41C7B0();
+ }
+}
+
+void Klayman::sub420E90() {
+ setFileHash(0x0928C048, 0, -1);
+ setCallback1(AnimationCallback(&Klayman::sub420EB0));
+}
+
+void Klayman::sub420EB0() {
+ _attachedSprite->sendMessage(0x482A, 0, this);
+}
+
+void Klayman::sub420680() {
+ if (!sub41CF10(AnimationCallback(&Klayman::sub420680))) {
+ _status2 = 2;
+ _counter2 = 0;
+ for (uint32 i = 0; i < 20; i++) {
+ if (getSubVar(0x02038314, i)) {
+ setSubVar(0x02720344, i, 1);
+ setSubVar(0x02038314, i, 0);
+ _counter2++;
+ }
+ }
+ if (_counter2 == 0) {
+ setCallback2(NULL);
+ sub41C7B0();
+ } else {
+ setFileHash(0xD8C8D100, 0, -1);
+ SetUpdateHandler(&Klayman::update);
+ SetSpriteCallback(&Klayman::spriteUpdate41F250);
+ SetMessageHandler(&Klayman::handleMessage41DB90);
+ _flagE5 = false;
+ _counter2--;
+ }
+ }
+}
+
+uint32 Klayman::handleMessage41DB90(int messageNum, const MessageParam &param, Entity *sender) {
+ switch (messageNum) {
+ case 0x100D:
+ if (param.asInteger() == 0x06040580) {
+ if (_counter2 == 0) {
+ // TODO: Calc calcHash value somewhere else
+ setFileHash3(0xD8C8D100, calcHash("GoToStartLoop/Finish"), 0);
+ }
+ } else if (_counter2 != 0 && param.asInteger() == calcHash("GoToStartLoop/Finish")) {
+ _counter2--;
+ setFileHash2(0xD8C8D100, 0x01084280, 0);
+ } else if (param.asInteger() == 0x062A1510) {
+ _soundResource1.play(0x41688704);
+ } else if (param.asInteger() == 0x02B20220) {
+ _soundResource1.play(0xC5408620);
+ } else if (param.asInteger() == 0x0A720138) {
+ _soundResource1.play(0xD4C08010);
+ } else if (param.asInteger() == 0xB613A180) {
+ _soundResource1.play(0x44051000);
+ } else if (param.asInteger() == 0x0E040501) {
+ _soundResource1.play(0xC6A129C1);
+ }
+ }
+ return handleMessage41D480(messageNum, param, sender);
+}
+
//##############################################################################
// KmScene1001
@@ -1865,7 +2004,7 @@ KmScene1001::KmScene1001(NeverhoodEngine *vm, Entity *parentScene, int16 x, int1
}
uint32 KmScene1001::xHandleMessage(int messageNum, const MessageParam &param) {
- debug("KmScene1001::xHandleMessage() messageNum = %04X", messageNum);
+ //debug("KmScene1001::xHandleMessage() messageNum = %04X", messageNum);
switch (messageNum) {
case 0x4001:
case 0x4800:
@@ -1951,7 +2090,7 @@ void KmScene1001::sub44FA50() {
}
uint32 KmScene1001::handleMessage44FA00(int messageNum, const MessageParam &param, Entity *sender) {
- debug("KmScene1001::handleMessage44FA00(%04X)", messageNum);
+ //debug("KmScene1001::handleMessage44FA00(%04X)", messageNum);
uint32 messageResult = Klayman::handleMessage41E210(messageNum, param, sender);
switch (messageNum) {
case 0x100D:
@@ -1987,7 +2126,7 @@ void KmScene1002::xUpdate() {
uint32 KmScene1002::xHandleMessage(int messageNum, const MessageParam &param) {
//ok
- debug("KmScene1002::xHandleMessage(%04X)", messageNum);
+ //debug("KmScene1002::xHandleMessage(%04X)", messageNum);
switch (messageNum) {
case 0x2001:
setCallback2(AnimationCallback(&KmScene1002::sub449E90));
@@ -2089,7 +2228,7 @@ uint32 KmScene1002::xHandleMessage(int messageNum, const MessageParam &param) {
}
void KmScene1002::update4497D0() {
- debug("KmScene1002::update4497D0()");
+ //debug("KmScene1002::update4497D0()");
Klayman::update();
if (_counter1 != 0 && (--_counter1 == 0)) {
_surface->setVisible(true);
@@ -2259,10 +2398,10 @@ uint32 KmScene1002::handleMessage449D60(int messageNum, const MessageParam &para
}
void KmScene1002::spriteUpdate449DC0() {
- debug("KmScene1002::spriteUpdate449DC0()");
+ //debug("KmScene1002::spriteUpdate449DC0()");
AnimatedSprite::updateDeltaXY();
HitRect *hitRect = _vm->_collisionMan->findHitRectAtPos(_x, _y + 10);
- debug("$$$ hitRect->type = %04X", hitRect->type);
+ //debug("$$$ hitRect->type = %04X", hitRect->type);
if (hitRect->type == 0x5001) {
_y = hitRect->rect.y1;
processDelta();
@@ -2272,7 +2411,7 @@ void KmScene1002::spriteUpdate449DC0() {
}
void KmScene1002::sub449E20() {
- debug("KmScene1002::sub449E20()");
+ //debug("KmScene1002::sub449E20()");
if (!sub41CEB0(AnimationCallback(&KmScene1002::sub449E20))) {
_status2 = 2;
_flagE5 = false;
@@ -2286,7 +2425,7 @@ void KmScene1002::sub449E20() {
}
void KmScene1002::sub449E90() {
- debug("KmScene1002::sub449E90()");
+ //debug("KmScene1002::sub449E90()");
_soundResource1.play(0x56548280);
_status2 = 0;
_flagE5 = false;
@@ -2299,7 +2438,7 @@ void KmScene1002::sub449E90() {
void KmScene1002::sub449EF0() {
//ok
- debug("KmScene1002::sub449EF0()");
+ //debug("KmScene1002::sub449EF0()");
_counter1 = 1;
_status2 = 0;
_flagE5 = false;
@@ -2318,7 +2457,7 @@ void KmScene1002::sub449EF0() {
void KmScene1002::sub449F70() {
//ok
- debug("KmScene1002::sub449F70()");
+ //debug("KmScene1002::sub449F70()");
_parentScene->sendMessage(0x1024, 1, this);
_soundResource1.play(0x41648271);
_status2 = 1;
@@ -2338,7 +2477,7 @@ void KmScene1002::sub449F70() {
void KmScene1002::sub44A050() {
//ok
- debug("KmScene1002::sub44A050()");
+ //debug("KmScene1002::sub44A050()");
_counter1 = 1;
_status2 = 0;
_flagE5 = false;
@@ -2353,7 +2492,7 @@ void KmScene1002::sub44A050() {
void KmScene1002::sub44A0D0() {
//ok
- debug("KmScene1002::sub44A0D0()");
+ //debug("KmScene1002::sub44A0D0()");
_counter1 = 1;
_status2 = 0;
_flagE5 = false;
@@ -2368,7 +2507,7 @@ void KmScene1002::sub44A0D0() {
void KmScene1002::sub44A150() {
//ok
- debug("KmScene1002::sub44A150()");
+ //debug("KmScene1002::sub44A150()");
_parentScene->sendMessage(0x1024, 1, this);
_soundResource1.play(0x41648271);
_status2 = 1;
@@ -2388,14 +2527,14 @@ void KmScene1002::sub44A150() {
void KmScene1002::sub44A230() {
//ok
- debug("KmScene1002::sub44A230()");
+ //debug("KmScene1002::sub44A230()");
setDoDeltaX(2);
sub41FC80();
}
void KmScene1002::sub44A250() {
//ok
- debug("KmScene1002::sub44A250()");
+ //debug("KmScene1002::sub44A250()");
if (!sub41CEB0(AnimationCallback(&KmScene1002::sub44A250))) {
_parentScene->sendMessage(0x1024, 3, this);
_status2 = 2;
@@ -2410,7 +2549,7 @@ void KmScene1002::sub44A250() {
void KmScene1002::sub44A2C0() {
//ok
- debug("KmScene1002::sub44A2C0()");
+ //debug("KmScene1002::sub44A2C0()");
if (_attachedSprite) {
_x = ((Sprite*)_attachedSprite)->getX();
_attachedSprite->sendMessage(0x4807, 0, this);
@@ -2427,7 +2566,7 @@ void KmScene1002::sub44A2C0() {
void KmScene1002::sub44A330() {
//ok
- debug("KmScene1002::sub44A330()");
+ //debug("KmScene1002::sub44A330()");
_status2 = 2;
_flagE5 = true;
setDoDeltaX(0);
@@ -2439,7 +2578,7 @@ void KmScene1002::sub44A330() {
void KmScene1002::sub44A370() {
//ok
- debug("KmScene1002::sub44A370()");
+ //debug("KmScene1002::sub44A370()");
_status2 = 1;
_flagE5 = false;
setFileHash(0x35AA8059, 0, -1);
@@ -2450,13 +2589,13 @@ void KmScene1002::sub44A370() {
}
void KmScene1002::sub44A3C0() {
- debug("KmScene1002::sub44A3C0()");
+ //debug("KmScene1002::sub44A3C0()");
_parentScene->sendMessage(0x1024, 1, this);
}
void KmScene1002::sub44A3E0() {
//ok
- debug("KmScene1002::sub44A3E0()");
+ //debug("KmScene1002::sub44A3E0()");
if (!sub41CEB0(AnimationCallback(&KmScene1002::sub44A3E0))) {
_status2 = 2;
_flagE4 = false;
@@ -2472,7 +2611,7 @@ void KmScene1002::sub44A3E0() {
void KmScene1002::sub44A460() {
//ok
- debug("KmScene1002::sub44A460()");
+ //debug("KmScene1002::sub44A460()");
_flagE4 = false;
_flagE5 = true;
setFileHash2(0x5C01A870, 0x01084280, 0);
@@ -2898,6 +3037,146 @@ uint32 KmScene1402::xHandleMessage(int messageNum, const MessageParam &param) {
return 0;
}
+// KmScene1403
+
+KmScene1403::KmScene1403(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y)
+ : Klayman(vm, parentScene, x, y, 1000, 1000) {
+
+ setKlaymanTable(klaymanTable4, ARRAYSIZE(klaymanTable4));
+}
+
+uint32 KmScene1403::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 0x480A:
+ if (param.asInteger() == 1) {
+ setCallback2(AnimationCallback(&Klayman::sub420600));
+ } else {
+ setCallback2(AnimationCallback(&Klayman::sub420550));
+ }
+ break;
+ case 0x480D:
+ setCallback2(AnimationCallback(&KmScene1001::sub420C50));
+ 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 0x4827:
+ setCallback2(AnimationCallback(&Klayman::sub420E20));
+ break;
+ case 0x483F:
+ sub41CD00(param.asInteger());
+ break;
+ case 0x4840:
+ sub41CD70(param.asInteger());
+ break;
+ }
+ return 0;
+}
+
+// KmScene1404
+
+KmScene1404::KmScene1404(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y)
+ : Klayman(vm, parentScene, x, y, 1000, 1000) {
+
+ // Empty
+}
+
+uint32 KmScene1404::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 0x480A:
+ if (param.asInteger() == 1) {
+ setCallback2(AnimationCallback(&Klayman::sub420600));
+ } else {
+ setCallback2(AnimationCallback(&Klayman::sub420550));
+ }
+ 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 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:
+ setCallback2(AnimationCallback(&Klayman::sub4207A0));
+ break;
+ case 0x481E:
+ 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 0x483F:
+ sub41CD00(param.asInteger());
+ break;
+ case 0x4840:
+ sub41CD70(param.asInteger());
+ break;
+ }
+ return 0;
+}
+
// KmScene1705
KmScene1705::KmScene1705(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y)
diff --git a/engines/neverhood/klayman.h b/engines/neverhood/klayman.h
index 5cb11abd10..d7c351e20c 100644
--- a/engines/neverhood/klayman.h
+++ b/engines/neverhood/klayman.h
@@ -99,6 +99,16 @@ public:
void sub420660();
void sub4205C0();
void sub420550();
+ void sub420C50();
+ void sub420CD0();
+ void sub420D10();
+ void sub420D50();
+ void sub420DA0();
+ void sub420DE0();
+ void sub420E20();
+ void sub420E90();
+ void sub420EB0();
+ void sub420680();
void spriteUpdate41F250();
void spriteUpdate41F5F0();
@@ -230,6 +240,8 @@ protected:
void update41D1C0();
+ uint32 handleMessage41DB90(int messageNum, const MessageParam &param, Entity *sender);
+
};
class KmScene1001 : public Klayman {
@@ -320,6 +332,20 @@ protected:
uint32 xHandleMessage(int messageNum, const MessageParam &param);
};
+class KmScene1403 : public Klayman {
+public:
+ KmScene1403(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y);
+protected:
+ uint32 xHandleMessage(int messageNum, const MessageParam &param);
+};
+
+class KmScene1404 : public Klayman {
+public:
+ KmScene1404(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y);
+protected:
+ uint32 xHandleMessage(int messageNum, const MessageParam &param);
+};
+
class KmScene1705 : public Klayman {
public:
KmScene1705(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y);
diff --git a/engines/neverhood/module1400.cpp b/engines/neverhood/module1400.cpp
index 7d618f5319..4da5faa2ff 100644
--- a/engines/neverhood/module1400.cpp
+++ b/engines/neverhood/module1400.cpp
@@ -23,6 +23,7 @@
#include "neverhood/module1400.h"
#include "neverhood/module1000.h"
#include "neverhood/diskplayerscene.h"
+#include "neverhood/gamemodule.h"
#include "neverhood/navigationscene.h"
namespace Neverhood {
@@ -87,21 +88,21 @@ void Module1400::createScene1403(int which) {
_vm->gameState().sceneNum = 2;
// TODO Music18hList_stop(0x06333232, 0, 2);
// TODO Music18hList_play(0x624A220E, 0, 2, 1);
- // TODO _childObject = new Scene1403(_vm, this, which);
+ _childObject = new Scene1403(_vm, this, which);
SetUpdateHandler(&Module1400::updateScene1403);
}
void Module1400::createScene1404(int which) {
_vm->gameState().sceneNum = 3;
// TODO Music18hList_play(0x06333232, 0, 2, 1);
- // TODO _childObject = new Scene1404(_vm, this, which);
+ _childObject = new Scene1404(_vm, this, which);
SetUpdateHandler(&Module1400::updateScene1404);
}
void Module1400::createScene1405(int which) {
_vm->gameState().sceneNum = 4;
// TODO Music18hList_play(0x06333232, 0, 2, 1);
- // TODO _childObject = new Scene1405(_vm, this, which);
+ _childObject = new Scene1405(_vm, this, which);
SetUpdateHandler(&Module1400::updateScene1405);
}
@@ -109,7 +110,7 @@ void Module1400::createScene1406(int which) {
_vm->gameState().sceneNum = 5;
// TODO Music18hList_stop(0x06333232, 0, 2);
_childObject = new DiskplayerScene(_vm, this, 2);
- SetUpdateHandler(&Module1400::updateScene1405);
+ SetUpdateHandler(&Module1400::updateScene1406);
}
void Module1400::createScene1407(int which) {
@@ -176,6 +177,7 @@ void Module1400::updateScene1404() {
_done = false;
delete _childObject;
_childObject = NULL;
+ debug("Scene1404; _field20 = %d", _field20);
if (_field20 == 1) {
createScene1405(0);
_childObject->handleUpdate();
@@ -402,7 +404,7 @@ Class528::Class528(NeverhoodEngine *vm, Sprite *klayman, bool flag)
_x = 320;
_y = 240;
- createSurface1(100, 0x04551900);
+ createSurface1(0x04551900, 100);
SetUpdateHandler(&Class528::update);
SetMessageHandler(&Class528::handleMessage);
_newHashListIndex = -2;
@@ -1058,7 +1060,7 @@ Scene1402::Scene1402(NeverhoodEngine *vm, Module *parentModule, int which)
void Scene1402::update() {
if (_flag) {
- _background->getSurface()->getDrawRect().y = _vm->_rnd->getRandomNumber(10) - 10;
+ _background->getSurface()->getDrawRect().y = _vm->_rnd->getRandomNumber(10 - 1) - 10;
// TODO g_screen->field_26 = -10 - _background->getSurface()->getDrawRect().y;
} else {
_background->getSurface()->getDrawRect().y = -10;
@@ -1436,4 +1438,438 @@ uint32 Scene1407::handleMessage(int messageNum, const MessageParam &param, Entit
return 0;
}
+// Scene1403
+
+Scene1403::Scene1403(NeverhoodEngine *vm, Module *parentModule, int which)
+ : Scene(vm, parentModule, true), _class489(NULL), _flag(false) {
+
+ SetMessageHandler(&Scene1403::handleMessage);
+
+ setRectList(0x004B1FF8);
+ _surfaceFlag = true;
+
+ _background = addBackground(new DirtyBackground(_vm, 0x2110A234, 0, 0));
+ _palette = new Palette(_vm, 0x2110A234);
+ _palette->usePalette();
+ _mouseCursor = addSprite(new Mouse433(_vm, 0x0A230219, NULL));
+
+ _class401_1 = addSprite(new StaticSprite(_vm, 0x01102A33, 100));
+ _class401_1->getSurface()->setVisible(false);
+
+ _class401_2 = addSprite(new StaticSprite(_vm, 0x04442520, 995));
+
+ _class401_3 = addSprite(new StaticSprite(_vm, 0x08742271, 995));
+
+ _asTape1 = new AsScene1201Tape(_vm, this, 12, 1100, 201, 468, 0x9148A011);
+ addSprite(_asTape1);
+ _vm->_collisionMan->addSprite(_asTape1);
+ _asTape1->setRepl(64, 0);
+
+ _asTape2 = new AsScene1201Tape(_vm, this, 16, 1100, 498, 468, 0x9048A093);
+ addSprite(_asTape2);
+ _vm->_collisionMan->addSprite(_asTape2);
+ _asTape2->setRepl(64, 0);
+
+ if (which < 0) {
+ _klayman = new KmScene1403(_vm, this, 380, 463);
+ setMessageList(0x004B1F18);
+ } else {
+ _klayman = new KmScene1403(_vm, this, 640, 463);
+ setMessageList(0x004B1F20);
+ }
+ addSprite(_klayman);
+ _klayman->setRepl(64, 0);
+
+ if (getGlobalVar(0x04A105B3) == 4) {
+ Class489 *class489;
+ class489 = new Class489(_vm, this, _klayman, 0);
+ _class489 = class489;
+ addSprite(_class489);
+ _vm->_collisionMan->addSprite(_class489);
+ if (getGlobalVar(0x04A10F33) == 4) {
+ _klayman->sendEntityMessage(0x1014, _class489, this);
+ _klayman->setX(_class489->getX() + 100);
+ _klayman->processDelta();
+ setMessageList(0x004B1F70);
+ }
+ _class489->getSurface()->getClipRect().x1 = 0;
+ _class489->getSurface()->getClipRect().y1 = 0;
+ _class489->getSurface()->getClipRect().x2 = 640;
+ _class489->getSurface()->getClipRect().y2 = _class401_2->getSurface()->getDrawRect().y + _class401_2->getSurface()->getDrawRect().height;
+ class489->setRepl(64, 0);
+ }
+
+}
+
+uint32 Scene1403::handleMessage(int messageNum, const MessageParam &param, Entity *sender) {
+ Scene::handleMessage(messageNum, param, sender);
+ switch (messageNum) {
+ case 0x100D:
+ if (param.asInteger() == 0x88C11390) {
+ setRectList(0x004B2008);
+ _flag = true;
+ } else if (param.asInteger() == 0x08821382) {
+ _klayman->sendEntityMessage(0x1014, _class489, this);
+ setRectList(0x004B1FF8);
+ _flag = false;
+ }
+ break;
+ case 0x1019:
+ _parentModule->sendMessage(0x1009, 0, this);
+ break;
+ case 0x1022:
+ if (sender == _class489) {
+ if (param.asInteger() >= 1000) {
+ setSurfacePriority(_class401_3->getSurface(), 1100);
+ } else {
+ setSurfacePriority(_class401_3->getSurface(), 995);
+ }
+ }
+ break;
+ case 0x4807:
+ _class401_1->getSurface()->setVisible(false);
+ break;
+ case 0x480F:
+ _class401_1->getSurface()->setVisible(true);
+ break;
+ case 0x4826:
+ if (sender == _class489) {
+ if (_flag) {
+ setMessageList2(0x004B1FA8);
+ } else if (param.asInteger() == 1) {
+ _klayman->sendEntityMessage(0x1014, _class489, this);
+ setMessageList2(0x004B1F88);
+ } else if (_class489->sendMessage(0x480C, _klayman->getX() > _class489->getX() ? 1 : 0, this) != 0) {
+ _klayman->sendEntityMessage(0x1014, _class489, this);
+ setMessageList2(0x004B1F58);
+ } else {
+ setMessageList2(0x004B1F28);
+ }
+ } else if (sender == _asTape1 || sender == _asTape2) {
+ if (_flag) {
+ setMessageList2(0x004B1FA8);
+ } else if (_messageListStatus != 2) {
+ _klayman->sendEntityMessage(0x1014, sender, this);
+ setMessageList2(0x004B1FB8);
+ }
+ }
+ break;
+ }
+ return 0;
+}
+
+// Scene1404
+
+Scene1404::Scene1404(NeverhoodEngine *vm, Module *parentModule, int which)
+ : Scene(vm, parentModule, true), _class489(NULL), _class545(NULL) {
+
+ if (getGlobalVar(0xC0780812) && !getGlobalVar(0x13382860)) {
+ setGlobalVar(0x13382860, 5);
+ }
+
+ SetMessageHandler(&Scene1404::handleMessage);
+ _surfaceFlag = true;
+
+ setRectList(0x004B8D80);
+
+ _background = addBackground(new DirtyBackground(_vm, 0xAC0B006F, 0, 0));
+ _palette = new Palette(_vm, 0xAC0B006F);
+ _palette->addPalette(0x00801510, 0, 65, 0);
+ _palette->usePalette();
+ _mouseCursor = addSprite(new Mouse433(_vm, 0xB006BAC8, NULL));
+
+ if (getGlobalVar(0x13382860) == 5) {
+ // TODO _class545 = addSprite(new Class545(_vm, this, 2, 1100, 267, 411));
+ // TODO _vm->_collisionMan->addSprite(_class545);
+ }
+
+ _sprite1 = addSprite(new StaticSprite(_vm, 0x1900A1F8, 1100));
+
+ _asTape = addSprite(new AsScene1201Tape(_vm, this, 14, 1100, 281, 411, 0x9148A011));
+ _vm->_collisionMan->addSprite(_asTape);
+
+ if (which < 0) {
+ _klayman = new KmScene1404(_vm, this, 376, 406);
+ setMessageList(0x004B8C28);
+ } else if (which == 1) {
+ _klayman = new KmScene1404(_vm, this, 376, 406);
+ setMessageList(0x004B8C30);
+ } else if (which == 2) {
+ if (getGlobalVar(0xC0418A02)) {
+ _klayman = new KmScene1404(_vm, this, 347, 406);
+ _klayman->setDoDeltaX(1);
+ } else {
+ _klayman = new KmScene1404(_vm, this, 187, 406);
+ }
+ setMessageList(0x004B8D28);
+ } else {
+ _klayman = new KmScene1404(_vm, this, 30, 406);
+ setMessageList(0x004B8C38);
+ }
+ addSprite(_klayman);
+
+ if (getGlobalVar(0x04A105B3) == 3) {
+ _class489 = addSprite(new Class489(_vm, this, _klayman, 0));
+ _vm->_collisionMan->addSprite(_class489);
+ if (getGlobalVar(0x04A10F33) == 0) {
+ _klayman->sendEntityMessage(0x1014, _class489, this);
+ _klayman->setX(_class489->getX() - 100);
+ _klayman->processDelta();
+ setMessageList(0x004B8CB8);
+ }
+ _class489->getSurface()->getClipRect().x1 = _sprite1->getSurface()->getDrawRect().x;
+ _class489->getSurface()->getClipRect().y1 = 0;
+ _class489->getSurface()->getClipRect().x2 = 640;
+ _class489->getSurface()->getClipRect().y2 = 480;
+ }
+
+ _klayman->getSurface()->getClipRect().x1 = _sprite1->getSurface()->getDrawRect().x;
+ _klayman->getSurface()->getClipRect().y1 = 0;
+ _klayman->getSurface()->getClipRect().x2 = 640;
+ _klayman->getSurface()->getClipRect().y2 = 480;
+
+}
+
+Scene1404::~Scene1404() {
+ setGlobalVar(0xC0418A02, _klayman->isDoDeltaX() ? 1 : 0);
+}
+
+uint32 Scene1404::handleMessage(int messageNum, const MessageParam &param, Entity *sender) {
+ Scene::handleMessage(messageNum, param, sender);
+ switch (messageNum) {
+ case 0x100D:
+ if (param.asInteger() == 0x410650C2) {
+ if (_class489 && _class489->getX() == 220) {
+ setMessageList(0x004B8C40);
+ } else {
+ setMessageList(0x004B8CE8);
+ }
+ }
+ break;
+ case 0x1019:
+ _parentModule->sendMessage(0x1009, 0, this);
+ break;
+ case 0x4826:
+ if (sender == _class489) {
+ if (_class489->sendMessage(0x480C, _klayman->getX() > _class489->getX() ? 1 : 0, this) != 0) {
+ _klayman->sendEntityMessage(0x1014, _class489, this);
+ setMessageList2(0x004B8CA0);
+ } else {
+ setMessageList2(0x004B8C40);
+ }
+ } else if (sender == _asTape && _messageListStatus != 2) {
+ _klayman->sendEntityMessage(0x1014, _asTape, this);
+ setMessageList(0x004B8CD0);
+ } else if (sender == _class545 && _messageListStatus != 2) {
+ _klayman->sendEntityMessage(0x1014, _class545, this);
+ setMessageList(0x004B8D18);
+ }
+ break;
+ }
+ return 0;
+}
+
+// Scene1405
+
+static const NPoint kAsScene1405TileItemPositions[] = {
+ {100, 80},
+ {162, 78},
+ {222, 76},
+ {292, 76},
+ {356, 82},
+ {422, 84},
+ {488, 86},
+ {550, 90},
+ {102, 134},
+ {164, 132},
+ {224, 136},
+ {294, 136},
+ {360, 136},
+ {422, 138},
+ {484, 144},
+ {548, 146},
+ { 98, 196},
+ {160, 200},
+ {228, 200},
+ {294, 202},
+ {360, 198},
+ {424, 200},
+ {482, 202},
+ {548, 206},
+ { 98, 260},
+ {160, 264},
+ {226, 260},
+ {296, 262},
+ {358, 260},
+ {424, 262},
+ {486, 264},
+ {550, 266},
+ { 94, 322},
+ {160, 316},
+ {226, 316},
+ {296, 320},
+ {358, 322},
+ {422, 324},
+ {488, 322},
+ {550, 322},
+ { 98, 380},
+ {160, 376},
+ {226, 376},
+ {294, 378},
+ {356, 380},
+ {420, 380},
+ {490, 378},
+ {552, 376}
+};
+
+AsScene1405Tile::AsScene1405Tile(NeverhoodEngine *vm, Scene1405 *parentScene, uint32 index)
+ : AnimatedSprite(vm, 1100), _parentScene(parentScene), _soundResource(vm),
+ _index(index), _countdown(0), _flag(false) {
+
+ _soundResource.load(0x05308101);
+ // TODO _soundResource.setPan
+ _x = kAsScene1405TileItemPositions[_index].x;
+ _y = kAsScene1405TileItemPositions[_index].y;
+ createSurface1(0x844B805C, 1100);
+ _surface->setVisible(false);
+ if (getSubVar(0xCCE0280F, _index))
+ _countdown = _vm->_rnd->getRandomNumber(36 - 1) + 1;
+ SetUpdateHandler(&AsScene1405Tile::update);
+ SetMessageHandler(&AsScene1405Tile::handleMessage);
+
+ debug("getSubVar(0x0C65F80B, _index) = %d", getSubVar(0x0C65F80B, _index));
+
+ setFileHash(0x844B805C, getSubVar(0x0C65F80B, _index), -1);
+ _newHashListIndex = (int16)getSubVar(0x0C65F80B, _index);
+}
+
+void AsScene1405Tile::update() {
+ updateAnim();
+ updatePosition();
+ if (_countdown != 0 && (--_countdown == 0)) {
+ show();
+ }
+}
+
+uint32 AsScene1405Tile::handleMessage(int messageNum, const MessageParam &param, Entity *sender) {
+ uint32 messageResult = Sprite::handleMessage(messageNum, param, sender);
+ switch (messageNum) {
+ case 0x1011:
+ if (getSubVar(0xCCE0280F, _index) == 0 && _parentScene->getCountdown() == 0) {
+ show();
+ _parentScene->sendMessage(0x2000, _index, this);
+ }
+ messageResult = 1;
+ break;
+ }
+ return messageResult;
+}
+
+void AsScene1405Tile::show() {
+ if (!_flag) {
+ _flag = true;
+ _soundResource.play();
+ _surface->setVisible(true);
+ }
+}
+
+void AsScene1405Tile::hide() {
+ if (_flag) {
+ _flag = false;
+ _soundResource.play();
+ _surface->setVisible(false);
+ }
+}
+
+Scene1405::Scene1405(NeverhoodEngine *vm, Module *parentModule, int which)
+ : Scene(vm, parentModule, true), _soundResource(vm), _selectFirstTile(true),
+ _tilesLeft(48), _countdown(0) {
+
+ _vm->gameModule()->initScene1405Vars();
+ _surfaceFlag = true;
+
+ _background = addBackground(new DirtyBackground(_vm, 0x0C0C007D, 0, 0));
+ _palette = new Palette(_vm, 0x0C0C007D);
+ _palette->usePalette();
+ _mouseCursor = addSprite(new Mouse435(_vm, 0xC00790C8, 20, 620));
+
+ // TODO: Some debug code: Leave two matching tiles open
+ for (int i = 0; i < 48; i++)
+ setSubVar(0xCCE0280F, i, 1);
+ int debugIndex = 0;
+ setSubVar(0xCCE0280F, debugIndex, 0);
+ for (int i = 0; i < 48; i++) {
+ if (i != debugIndex && getSubVar(0x0C65F80B, i) == getSubVar(0x0C65F80B, debugIndex)) {
+ setSubVar(0xCCE0280F, i, 0);
+ break;
+ }
+ }
+
+ for (uint32 index = 0; index < 48; index++) {
+ _tiles[index] = new AsScene1405Tile(_vm, this, index);
+ addSprite(_tiles[index]);
+ _vm->_collisionMan->addSprite(_tiles[index]);
+ if (getSubVar(0xCCE0280F, index))
+ _tilesLeft--;
+ }
+
+ _soundResource.load(0x68E25540);
+
+ SetMessageHandler(&Scene1405::handleMessage);
+ SetUpdateHandler(&Scene1405::update);
+
+}
+
+void Scene1405::update() {
+ Scene::update();
+ if (_countdown != 0 && (--_countdown == 0)) {
+ _tilesLeft = 48;
+ _tiles[_firstTileIndex]->hide();
+ _tiles[_secondTileIndex]->hide();
+ for (uint32 i = 0; i < 48; i++) {
+ if (getSubVar(0xCCE0280F, i)) {
+ _tiles[i]->hide();
+ setSubVar(0xCCE0280F, i, 0);
+ }
+ }
+ }
+}
+
+uint32 Scene1405::handleMessage(int messageNum, const MessageParam &param, Entity *sender) {
+ Scene::handleMessage(messageNum, param, sender);
+ switch (messageNum) {
+ case 0x0001:
+ // TODO: Debug/Cheat stuff
+ if (param.asPoint().x <= 20 || param.asPoint().x >= 620) {
+ _parentModule->sendMessage(0x1009, 0, this);
+ }
+ break;
+ case 0x000D:
+ // TODO: Debug/Cheat stuff
+ break;
+ case 0x2000:
+ if (_selectFirstTile) {
+ _firstTileIndex = param.asInteger();
+ _selectFirstTile = false;
+ } else {
+ _secondTileIndex = param.asInteger();
+ if (_firstTileIndex != _secondTileIndex) {
+ _selectFirstTile = true;
+ if (getSubVar(0x0C65F80B, _secondTileIndex) == getSubVar(0x0C65F80B, _firstTileIndex)) {
+ setSubVar(0xCCE0280F, _firstTileIndex, 1);
+ setSubVar(0xCCE0280F, _secondTileIndex, 1);
+ _tilesLeft -= 2;
+ if (_tilesLeft == 0) {
+ _soundResource.play();
+ }
+ } else {
+ _countdown = 10;
+ }
+ }
+ }
+ break;
+ }
+ return 0;
+}
+
} // End of namespace Neverhood
diff --git a/engines/neverhood/module1400.h b/engines/neverhood/module1400.h
index 433dc413f5..72afb4f15a 100644
--- a/engines/neverhood/module1400.h
+++ b/engines/neverhood/module1400.h
@@ -26,6 +26,7 @@
#include "neverhood/neverhood.h"
#include "neverhood/module.h"
#include "neverhood/scene.h"
+#include "neverhood/module1200.h"
namespace Neverhood {
@@ -237,6 +238,71 @@ protected:
uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
};
+// Scene1403
+
+class Scene1403 : public Scene {
+public:
+ Scene1403(NeverhoodEngine *vm, Module *parentModule, int which);
+protected:
+ Sprite *_class401_1;
+ Sprite *_class401_2;
+ Sprite *_class401_3;
+ AsScene1201Tape *_asTape1;
+ AsScene1201Tape *_asTape2;
+ Sprite *_class489;
+ bool _flag;
+ uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
+};
+
+// Scene1404
+
+class Scene1404 : public Scene {
+public:
+ Scene1404(NeverhoodEngine *vm, Module *parentModule, int which);
+ virtual ~Scene1404();
+protected:
+ Sprite *_sprite1;
+ Sprite *_asTape;
+ Sprite *_class489;
+ Sprite *_class545;
+ uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
+};
+
+// Scene1405
+
+class Scene1405;
+
+class AsScene1405Tile : public AnimatedSprite {
+public:
+ AsScene1405Tile(NeverhoodEngine *vm, Scene1405 *parentScene, uint32 index);
+ void show();
+ void hide();
+protected:
+ Scene1405 *_parentScene;
+ SoundResource _soundResource;
+ bool _flag;
+ uint32 _index;
+ int _countdown;
+ void update();
+ uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
+};
+
+class Scene1405 : public Scene {
+public:
+ Scene1405(NeverhoodEngine *vm, Module *parentModule, int which);
+ int getCountdown() const { return _countdown; }
+protected:
+ SoundResource _soundResource;
+ bool _selectFirstTile;
+ int _firstTileIndex;
+ int _secondTileIndex;
+ int _tilesLeft;
+ int _countdown;
+ AsScene1405Tile *_tiles[48];
+ void update();
+ uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
+};
+
} // End of namespace Neverhood
#endif /* NEVERHOOD_MODULE1400_H */
diff --git a/engines/neverhood/neverhood.cpp b/engines/neverhood/neverhood.cpp
index 1f253c0a15..0db5d62c2c 100644
--- a/engines/neverhood/neverhood.cpp
+++ b/engines/neverhood/neverhood.cpp
@@ -156,8 +156,11 @@ Common::Error NeverhoodEngine::run() {
#endif
#if 1
+
_collisionMan = new CollisionMan(this);
_gameModule = new GameModule(this);
+
+ _gameModule->startup();
// Preliminary main loop, needs some more work but works for testing
while (!shouldQuit()) {
@@ -181,14 +184,9 @@ Common::Error NeverhoodEngine::run() {
case Common::EVENT_RBUTTONDOWN:
_gameModule->handleMouseDown(event.mouse.x, event.mouse.y);
break;
- /*
- case Common::EVENT_LBUTTONUP:
- case Common::EVENT_RBUTTONUP:
- break;
case Common::EVENT_QUIT:
_system->quit();
break;
- */
default:
break;
}
diff --git a/engines/neverhood/neverhood.h b/engines/neverhood/neverhood.h
index 86f7a0ad33..edb204c92d 100644
--- a/engines/neverhood/neverhood.h
+++ b/engines/neverhood/neverhood.h
@@ -118,6 +118,7 @@ public:
#endif
GameState& gameState() { return _gameState; }
+ GameModule *gameModule() { return _gameModule; }
int16 getMouseX() const { return _mouseX; }
int16 getMouseY() const { return _mouseY; }
NPoint getMousePos();
diff --git a/engines/neverhood/scene.cpp b/engines/neverhood/scene.cpp
index d725cedb99..b9a464c1e9 100644
--- a/engines/neverhood/scene.cpp
+++ b/engines/neverhood/scene.cpp
@@ -505,7 +505,7 @@ void Scene::setRectList(RectList *rectList) {
void Scene::clearRectList() {
_rectList = NULL;
- _rectType = 1;
+ _rectType = 0;
}
void Scene::loadDataResource(uint32 fileHash) {
diff --git a/engines/neverhood/sprite.h b/engines/neverhood/sprite.h
index 86165f3440..a518c39da2 100644
--- a/engines/neverhood/sprite.h
+++ b/engines/neverhood/sprite.h
@@ -30,7 +30,7 @@
namespace Neverhood {
-#define SetSpriteCallback(callback) _spriteUpdateCb = static_cast <void (Sprite::*)(void)> (callback); debug("SetSpriteCallback(" #callback ")"); _spriteUpdateCbName = #callback
+#define SetSpriteCallback(callback) _spriteUpdateCb = static_cast <void (Sprite::*)(void)> (callback); debug(2, "SetSpriteCallback(" #callback ")"); _spriteUpdateCbName = #callback
#define SetFilterX(callback) _filterXCb = static_cast <int16 (Sprite::*)(int16)> (callback); debug("SetFilterX(" #callback ")")
#define SetFilterY(callback) _filterYCb = static_cast <int16 (Sprite::*)(int16)> (callback); debug("SetFilterY(" #callback ")")