aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/neverhood/entity.h2
-rw-r--r--engines/neverhood/gamemodule.cpp11
-rw-r--r--engines/neverhood/gamemodule.h1
-rw-r--r--engines/neverhood/klayman.cpp65
-rw-r--r--engines/neverhood/klayman.h2
-rw-r--r--engines/neverhood/module1000.cpp32
-rw-r--r--engines/neverhood/neverhood.cpp8
-rw-r--r--engines/neverhood/scene.cpp33
-rw-r--r--engines/neverhood/scene.h3
9 files changed, 126 insertions, 31 deletions
diff --git a/engines/neverhood/entity.h b/engines/neverhood/entity.h
index 317672c7fe..64c1181089 100644
--- a/engines/neverhood/entity.h
+++ b/engines/neverhood/entity.h
@@ -70,7 +70,7 @@ public:
uint32 sendMessage(int messageNum, uint32 param, Entity *sender) {
return sendMessage(messageNum, MessageParam(param), sender);
}
- uint32 sendPointMessage(int messageNum, NPoint param, Entity *sender) {
+ uint32 sendPointMessage(int messageNum, const NPoint &param, Entity *sender) {
return sendMessage(messageNum, MessageParam(param), sender);
}
uint32 sendEntityMessage(int messageNum, Entity *param, Entity *sender) {
diff --git a/engines/neverhood/gamemodule.cpp b/engines/neverhood/gamemodule.cpp
index 93687f9866..c63131dcf3 100644
--- a/engines/neverhood/gamemodule.cpp
+++ b/engines/neverhood/gamemodule.cpp
@@ -22,6 +22,7 @@
#include "neverhood/gamemodule.h"
+#include "neverhood/graphics.h"
#include "neverhood/module1000.h"
#include "neverhood/module1500.h"
@@ -57,6 +58,16 @@ GameModule::~GameModule() {
}
+void GameModule::handleMouseDown(int16 x, int16 y) {
+ if (_childObject) {
+ NPoint mousePos;
+ mousePos.x = x;
+ mousePos.y = y;
+ debug("GameModule::handleMouseDown(%d, %d)", x, y);
+ _childObject->sendPointMessage(1, mousePos, this);
+ }
+}
+
uint32 GameModule::handleMessage(int messageNum, const MessageParam &param, Entity *sender) {
uint32 messageResult = Module::handleMessage(messageNum, param, sender);
switch (messageNum) {
diff --git a/engines/neverhood/gamemodule.h b/engines/neverhood/gamemodule.h
index 6d65895ef7..7fce9ebaea 100644
--- a/engines/neverhood/gamemodule.h
+++ b/engines/neverhood/gamemodule.h
@@ -34,6 +34,7 @@ class GameModule : public Module {
public:
GameModule(NeverhoodEngine *vm);
virtual ~GameModule();
+ void handleMouseDown(int16 x, int16 y);
protected:
Entity *_prevChildObject;
bool _someFlag1;
diff --git a/engines/neverhood/klayman.cpp b/engines/neverhood/klayman.cpp
index 836b2e0bb0..7a775bcf12 100644
--- a/engines/neverhood/klayman.cpp
+++ b/engines/neverhood/klayman.cpp
@@ -67,9 +67,22 @@ Klayman::Klayman(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y, int
}
void Klayman::xUpdate() {
+ // Empty
}
uint32 Klayman::xHandleMessage(int messageNum, const MessageParam &param) {
+ switch (messageNum) {
+ case 0x4001:
+ case 0x4800:
+ sub41C930(param._point.x, false);
+ break;
+ case 0x4004:
+ // TODO AnimatedSprite_setCallback2(AnimationCallback(&sub41FC80));
+ break;
+ case 0x4818:
+ // TODO sub41C930(_rectResource.getRectangle1(param._integer).x, false);
+ break;
+ }
return 0;
}
@@ -455,5 +468,57 @@ void Klayman::sub41FCF0() {
SetSpriteCallback(NULL);
}
+uint32 Klayman::handleMessage41F140(int messageNum, const MessageParam &param, Entity *sender) {
+ uint32 messageResult = handleMessage41D480(messageNum, param, sender);
+ switch (messageNum) {
+ case 0x100D:
+ if (param._integer == 0x271AA210) {
+#if 0
+ _soundResource1.set(0x4924AAC4);
+ _soundResource1.load();
+ _soundResource1.play(false);
+#endif
+ } else if (param._integer == 0x2B22AA81) {
+#if 0
+ _soundResource1.set(0x0A2AA8E0);
+ _soundResource1.load();
+ _soundResource1.play(false);
+#endif
+ }
+ break;
+ }
+ return messageResult;
+}
+
+
+void Klayman::sub41C930(int16 x, bool flag) {
+ int16 xdiff = ABS(x - _x);
+ if (xdiff == 0) {
+ _x4 = x;
+ if (_flagE1 || _flagE2 || _flagE3) {
+ // TODO AnimatedSprite_setCallback2(NULL);
+ sub41C7B0();
+ }
+ } else if (xdiff <= 36 && !_flagE1 && !_flagE2 && !_flagE3) {
+ _x4 = x;
+ // TODO AnimatedSprite_setCallback2(NULL);
+ sub41C7B0();
+ } else if (xdiff <= 42 && _status != 3) {
+ if (_flagE2 && ((!_doDeltaX && x - _x > 0) || (_doDeltaX && x - _x < 0)) && ABS(_x4 - _x) > xdiff) {
+ _x4 = x;
+ } else {
+ _x4 = x;
+ // TODO AnimatedSprite_setCallback2(AnimationCallback(&Klayman::sub41FB40));
+ }
+ } else if (_flagE1 && ((!_doDeltaX && x - _x > 0) || (_doDeltaX && x - _x < 0))) {
+ _x4 = x;
+ } else if (flag) {
+ _x4 = x;
+ // TODO AnimatedSprite_setCallback2(AnimationCallback(&Klayman::sub421550));
+ } else {
+ _x4 = x;
+ // TODO AnimatedSprite_setCallback2(AnimationCallback(&Klayman::sub41F950));
+ }
+}
} // End of namespace Neverhood
diff --git a/engines/neverhood/klayman.h b/engines/neverhood/klayman.h
index d953f5565f..69f9a34dc6 100644
--- a/engines/neverhood/klayman.h
+++ b/engines/neverhood/klayman.h
@@ -124,6 +124,8 @@ protected:
void sub41FCF0();
uint32 handleMessage41F140(int messageNum, const MessageParam &param, Entity *sender);
+
+ void sub41C930(int16 x, bool flag);
};
diff --git a/engines/neverhood/module1000.cpp b/engines/neverhood/module1000.cpp
index 7ee1090cb8..858062084f 100644
--- a/engines/neverhood/module1000.cpp
+++ b/engines/neverhood/module1000.cpp
@@ -400,41 +400,45 @@ Scene1001::Scene1001(NeverhoodEngine *vm, Module *parentModule, int which)
// TODO Mouse
+ //DEBUG so he's here at least
+ _klayman = new Klayman(_vm, this, 200, 433, 1000, 1000);
+ addSprite(_klayman);
+
#if 0
// TODO: Player sprites...
if (which < 0) {
setRectList(0x004B49F0);
- _playerSprite = new Class572(_vm, this, 200, 433, 1000, 1000);
+ _klayman = new Class572(_vm, this, 200, 433, 1000, 1000);
setMessageList(0x004B4888);
} else if (which == 1) {
setRectList(0x004B49F0);
- _playerSprite = new Class572(_vm, this, 640, 433, 1000, 1000);
+ _klayman = new Class572(_vm, this, 640, 433, 1000, 1000);
setMessageList(0x004B4898);
} else if (which == 2) {
setRectList(0x004B49F0);
if (_vm->getGlobalVar(0xC0418A02)) {
- _playerSprite = new Class572(_vm, this, 390, 433, 1000, 1000);
- _playerSprite->setDoDeltaX(1);
+ _klayman = new Class572(_vm, this, 390, 433, 1000, 1000);
+ _klayman->setDoDeltaX(1);
} else {
- _playerSprite = new Class572(_vm, this, 300, 433, 1000, 1000);
+ _klayman = new Class572(_vm, this, 300, 433, 1000, 1000);
}
setMessageList(0x004B4970);
} else {
setRectList(0x004B4A00);
- _playerSprite = new Class572(_vm, this, 200, 433, 1000, 1000);
+ _klayman = new Class572(_vm, this, 200, 433, 1000, 1000);
setMessageList(0x004B4890);
}
- addSprite(_playerSprite);
+ addSprite(_klayman);
#endif
staticSprite1 = addSprite(new StaticSprite(_vm, 0x2080A3A8, 1300));
#if 0
// TODO: This sucks somehow, find a better way
- _playerSprite->getSurface()->getClipRect().x1 = 0;
- _playerSprite->getSurface()->getClipRect().y1 = 0;
- _playerSprite->getSurface()->getClipRect().x2 = staticSprite1->getSurface()->getDrawRect().x + staticSprite1->getSurface()->getDrawRect().width;
- _playerSprite->getSurface()->getClipRect().y2 = 480;
+ _klayman->getSurface()->getClipRect().x1 = 0;
+ _klayman->getSurface()->getClipRect().y1 = 0;
+ _klayman->getSurface()->getClipRect().x2 = staticSprite1->getSurface()->getDrawRect().x + staticSprite1->getSurface()->getDrawRect().width;
+ _klayman->getSurface()->getClipRect().y2 = 480;
#endif
if (_vm->getGlobalVar(0xD217189D) == 0) {
@@ -470,7 +474,7 @@ Scene1001::Scene1001(NeverhoodEngine *vm, Module *parentModule, int which)
}
Scene1001::~Scene1001() {
- // TODO _vm->setGlobalVar(0xC0418A02, _playerSprite->_doDeltaX);
+ // TODO _vm->setGlobalVar(0xC0418A02, _klayman->_doDeltaX);
}
uint32 Scene1001::handleMessage(int messageNum, const MessageParam &param, Entity *sender) {
@@ -490,7 +494,7 @@ uint32 Scene1001::handleMessage(int messageNum, const MessageParam &param, Entit
break;
case 0x100D:
if (param._integer == 0x00342624) {
- // TODO _playerSprite->sendMessage(0x1014, _asLever, this);
+ // TODO _klayman->sendMessage(0x1014, _asLever, this);
// TODO setMessageList2(0x004B4910, true, false);
messageResult = 1;
} else if (param._integer == 0x21E64A00) {
@@ -502,7 +506,7 @@ uint32 Scene1001::handleMessage(int messageNum, const MessageParam &param, Entit
messageResult = 1;
}
} else if (param._integer == 0x040424D0) {
- // TODO _playerSprite->sendMessage(0x1014, _ssButton, this);
+ // TODO _klayman->sendMessage(0x1014, _ssButton, this);
} else if (param._integer == 0x80006358) {
if (_vm->getGlobalVar(0x03C698DA)) {
// TODO setMessageList(0x004B4938, true, false);
diff --git a/engines/neverhood/neverhood.cpp b/engines/neverhood/neverhood.cpp
index 4c80c40274..73e7c5fcd6 100644
--- a/engines/neverhood/neverhood.cpp
+++ b/engines/neverhood/neverhood.cpp
@@ -152,14 +152,18 @@ Common::Error NeverhoodEngine::run() {
_mouseX = event.mouse.x;
_mouseY = event.mouse.y;
break;
- /*
+
case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_RBUTTONDOWN:
+ _gameModule->handleMouseDown(event.mouse.x, event.mouse.y);
+ break;
+
+ /*
_buttonState |= kLeftButton;
break;
case Common::EVENT_LBUTTONUP:
_buttonState &= ~kLeftButton;
break;
- case Common::EVENT_RBUTTONDOWN:
_buttonState |= kRightButton;
break;
case Common::EVENT_RBUTTONUP:
diff --git a/engines/neverhood/scene.cpp b/engines/neverhood/scene.cpp
index b06caeec14..9b7b35d419 100644
--- a/engines/neverhood/scene.cpp
+++ b/engines/neverhood/scene.cpp
@@ -37,7 +37,7 @@ Scene::Scene(NeverhoodEngine *vm, Module *parentModule, bool clearHitRects)
_mouseClicked = false;
// TODO _rectList = NULL;
// TODO _someRects = NULL;
- // TODO _playerSprite = NULL;
+ _klayman = NULL;
// TODO _mouseSprite = NULL;
_palette = NULL;
_background = NULL;
@@ -193,15 +193,15 @@ void Scene::update() {
if (_mouseClicked) {
//** ALL TODO
#if 0
- if (_playerSprite) {
+ if (_klayman) {
// TODO: Merge later
- if (_playerSprite->hasMessageHandler() &&
- _playerSprite->sendMessage(0x1008, 0, this) != 0 &&
+ if (_klayman->hasMessageHandler() &&
+ _klayman->sendMessage(0x1008, 0, this) != 0 &&
_messageListFlag &&
queryPositionClass400(_mouseClickPos.x, _mouseClickPos.y)) {
_mouseClicked = false;
- } else if (_playerSprite->hasMessageHandler() &&
- _playerSprite->sendMessage(0x1008, 0, this) != 0 &&
+ } else if (_klayman->hasMessageHandler() &&
+ _klayman->sendMessage(0x1008, 0, this) != 0 &&
_messageListFlag) {
_mouseClicked = !queryPositionRectList(_mouseClickPos.x, _mouseClickPos.y);
}
@@ -223,12 +223,13 @@ void Scene::update() {
uint32 Scene::handleMessage(int messageNum, const MessageParam &param, Entity *sender) {
// TODO
-#if 0
switch (messageNum) {
case 0: // mouse moved
+#if 0
if (_mouseSprite && _mouseSprite->hasMessageHandler())
_mouseSprite->sendMessage(0x4002, param, this);
queryPositionSomeRects(param._point.x, param._point.y);
+#endif
break;
case 1: // mouse clicked
_mouseClicked = true;
@@ -245,7 +246,9 @@ uint32 Scene::handleMessage(int messageNum, const MessageParam &param, Entity *s
break;
*/
case 5:
+#if 0
broadcastObjectMessage5();
+#endif
break;
case 6:
_parentModule->sendMessage(0x1009, param, this);
@@ -254,35 +257,39 @@ uint32 Scene::handleMessage(int messageNum, const MessageParam &param, Entity *s
if (_messageListFlag1) {
_messageListFlag1 = false;
if (_messageListIndex == _messageListCount)
- _playerSprite->sendMessage(0x4004, 0, this);
- else
- runMessageList();
+ _klayman->sendMessage(0x4004, 0, this);
+ else {
+ // TODO runMessageList();
+ }
}
break;
case 0x1007:
if (_messageListFlag1) {
_messageListFlag1 = false;
_messageList = NULL;
- _playerSprite->sendMessage(0x4004, 0, this);
+ _klayman->sendMessage(0x4004, 0, this);
}
break;
case 0x101D:
+#if 0
if (_mouseSprite) {
_prevVisible = _mouseSprite->_drawSurface->_visible;
_mouseSprite->_drawSurface->_visible = false;
}
+#endif
break;
case 0x101E:
+#if 0
if (_prevVisible && _mouseSprite) {
_mouseSprite->_drawSurface->_visible = true;
_mouseSprite->sendMessage(0x4002, g_Screen->_mousePos, this);
}
+#endif
break;
case 0x1022:
- setSurfacePriority(((Sprite*)sender)->_surface, param._integer);
+ setSurfacePriority(((Sprite*)sender)->getSurface(), param._integer);
break;
}
-#endif
return 0;
}
diff --git a/engines/neverhood/scene.h b/engines/neverhood/scene.h
index 108adba83b..4928d20ae2 100644
--- a/engines/neverhood/scene.h
+++ b/engines/neverhood/scene.h
@@ -28,6 +28,7 @@
#include "neverhood/background.h"
#include "neverhood/entity.h"
#include "neverhood/graphics.h"
+#include "neverhood/klayman.h"
#include "neverhood/module.h"
#include "neverhood/palette.h"
#include "neverhood/smackerplayer.h"
@@ -67,8 +68,8 @@ protected:
// TODO 00000088 someRects dd ?
// TODO 0000008C someRectsCount dw ?
// TODO 0000008E field_8E dw ?
- // TODO 00000090 playerSprite dd ?
// TODO 00000094 mouseSprite dd ?
+ Klayman *_klayman;
Palette *_palette;
Background *_background;
bool _surfaceFlag;