aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjohndoe1232011-07-09 18:45:51 +0000
committerWillem Jan Palenstijn2013-05-08 20:38:46 +0200
commit222cd4a6513770914d09630d1001a8159ba3d0f9 (patch)
treef8c9e71c549c9a9c6e41073d9b9d3c6c8729848a
parent5c69ae21ddf535f862585a4fa5892a9a1146618f (diff)
downloadscummvm-rg350-222cd4a6513770914d09630d1001a8159ba3d0f9.tar.gz
scummvm-rg350-222cd4a6513770914d09630d1001a8159ba3d0f9.tar.bz2
scummvm-rg350-222cd4a6513770914d09630d1001a8159ba3d0f9.zip
NEVERHOOD: More work on Scene1001 and Klayman
- Fix a bug in Klayman's walking - The lever can now be used - Other stuff is still missing - Remove entity.cpp since it's not needed
-rw-r--r--engines/neverhood/entity.cpp27
-rw-r--r--engines/neverhood/entity.h4
-rw-r--r--engines/neverhood/klayman.cpp160
-rw-r--r--engines/neverhood/klayman.h4
-rw-r--r--engines/neverhood/module.mk1
-rw-r--r--engines/neverhood/module1000.cpp19
-rw-r--r--engines/neverhood/neverhood.cpp10
-rw-r--r--engines/neverhood/resource.cpp2
-rw-r--r--engines/neverhood/scene.cpp29
-rw-r--r--engines/neverhood/sprite.cpp28
-rw-r--r--engines/neverhood/sprite.h3
11 files changed, 182 insertions, 105 deletions
diff --git a/engines/neverhood/entity.cpp b/engines/neverhood/entity.cpp
deleted file mode 100644
index 9070d5c8c4..0000000000
--- a/engines/neverhood/entity.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "neverhood/entity.h"
-
-namespace Neverhood {
-
-} // End of namespace Neverhood
diff --git a/engines/neverhood/entity.h b/engines/neverhood/entity.h
index 29bf6be988..c570084e56 100644
--- a/engines/neverhood/entity.h
+++ b/engines/neverhood/entity.h
@@ -49,8 +49,8 @@ public:
assert(_type == mptInteger || _type == mptPoint);
if (_type == mptInteger) {
NPoint pt;
- pt.x = (_integer >> 16) & 0xFFFF;
- pt.y = _integer & 0xFFFF;
+ pt.x = _integer & 0xFFFF;
+ pt.y = (_integer >> 16) & 0xFFFF;
return pt;
}
return _point;
diff --git a/engines/neverhood/klayman.cpp b/engines/neverhood/klayman.cpp
index eca8e02df4..4a40b2f4b7 100644
--- a/engines/neverhood/klayman.cpp
+++ b/engines/neverhood/klayman.cpp
@@ -53,7 +53,7 @@ Klayman::Klayman(NeverhoodEngine *vm, Entity *parentScene, int16 x, int16 y, int
: AnimatedSprite(vm, objectPriority), _soundResource1(vm), _soundResource2(vm),
_counterMax(0), _counter(0), _flagE4(false), _counter3Max(0), _flagF8(false), _counter1(0),
_counter2(0), /*_field118(0), */_status2(0), _flagE5(true), _attachedSprite(NULL), _flagE1(false),
- _status(1), _parentScene(parentScene), _flagE2(false), _flagE3(false), _flagF6(false), _flagF7(false),
+ _status3(1), _parentScene(parentScene), _flagE2(false), _flagE3(false), _flagF6(false), _flagF7(false),
_flagFA(false), _statusE0(0), _field114(0), _resourceHandle(-1), _soundFlag(false) {
// TODO
@@ -289,22 +289,24 @@ void Klayman::update41D2B0() {
}
bool Klayman::sub41CF10(AnimationCb callback) {
- if (_status2 != 2)
- return false;
- _status2 = 1;
- setFileHash(0x9A7020B8, 0, -1);
- SetUpdateHandler(&Klayman::update);
- SetMessageHandler(&Klayman::handleMessage41F140);
- SetSpriteCallback(NULL);
- SetAnimationCallback3(callback);
- _flagE5 = false;
- return true;
+ if (_status2 == 2) {
+ _status2 = 1;
+ _flagE5 = false;
+ setFileHash(0x9A7020B8, 0, -1);
+ SetUpdateHandler(&Klayman::update);
+ SetMessageHandler(&Klayman::handleMessage41F140);
+ SetSpriteCallback(NULL);
+ SetAnimationCallback3(callback);
+ return true;
+ }
+ return false;
}
-void Klayman::sub41C7B0() {
+ void Klayman::sub41C7B0() {
if (_callback1Cb) {
- (this->*_callback1Cb)();
+ AnimationCb cb = _callback1Cb;
_callback1Cb = NULL;
+ (this->*cb)();
}
if (_callback3Cb) {
AnimationCb cb = _callback3Cb;
@@ -321,16 +323,18 @@ void Klayman::sub41C7B0() {
void Klayman::sub41C770() {
_flagFA = false;
- _status = 1;
+ _status3 = 1;
}
void Klayman::sub41C790() {
if (_flagFA)
- _status = 0;
+ _status3 = 0;
}
void Klayman::sub41FC80() {
if (!sub41CF10(AnimationCallback(&Klayman::sub41FC80))) {
+ _status2 = 1;
+ _flagE5 = true;
setFileHash(0x5420E254, 0, -1);
_counter = 0;
_counter3 = 0;
@@ -387,7 +391,7 @@ uint32 Klayman::handleMessage41D360(int messageNum, const MessageParam &param, E
sub41C790();
break;
case 0x481C:
- _status = param.asInteger();
+ _status3 = param.asInteger();
_flagFA = true;
messageResult = 1;
break;
@@ -413,6 +417,7 @@ void Klayman::sub41FF00() {
}
uint32 Klayman::handleMessage41D480(int messageNum, const MessageParam &param, Entity *sender) {
+ debug("Klayman::handleMessage41D480(%04X)", messageNum);
uint32 messageResult = handleMessage41D360(messageNum, param, sender);
switch (messageNum) {
case 0x3002:
@@ -432,6 +437,7 @@ void Klayman::sub41FCF0() {
}
uint32 Klayman::handleMessage41F140(int messageNum, const MessageParam &param, Entity *sender) {
+ debug("Klayman::handleMessage41F140(%04X)", messageNum);
uint32 messageResult = handleMessage41D480(messageNum, param, sender);
switch (messageNum) {
case 0x100D:
@@ -449,9 +455,9 @@ uint32 Klayman::handleMessage41F140(int messageNum, const MessageParam &param, E
void Klayman::sub41C930(int16 x, bool flag) {
debug("Klayman::sub41C930(%d, %d)", x, flag);
int16 xdiff = ABS(x - _x);
- if (xdiff == 0) {
+ if (x == _x) {
_x4 = x;
- if (_flagE1 || _flagE2 || _flagE3) {
+ if (!_flagE1 && !_flagE2 && !_flagE3) {
setCallback2(NULL);
sub41C7B0();
}
@@ -459,7 +465,7 @@ void Klayman::sub41C930(int16 x, bool flag) {
_x4 = x;
setCallback2(NULL);
sub41C7B0();
- } else if (xdiff <= 42 && _status != 3) {
+ } else if (xdiff <= 42 && _status3 != 3) {
if (_flagE2 && ((!_doDeltaX && x - _x > 0) || (_doDeltaX && x - _x < 0)) && ABS(_x4 - _x) > xdiff) {
_x4 = x;
} else {
@@ -470,7 +476,6 @@ void Klayman::sub41C930(int16 x, bool flag) {
_x4 = x;
} else if (flag) {
_x4 = x;
- debug("#### 1");
// TODO AnimatedSprite_setCallback2(AnimationCallback(&Klayman::sub421550));
} else {
_x4 = x;
@@ -497,6 +502,7 @@ void Klayman::sub4211B0() {
}
uint32 Klayman::handleMessage41E920(int messageNum, const MessageParam &param, Entity *sender) {
+ debug("Klayman::handleMessage41E920(%04X)", messageNum);
uint32 messageResult = handleMessage41D360(messageNum, param, sender);
switch (messageNum) {
case 0x100D:
@@ -526,10 +532,82 @@ bool Klayman::sub41CEB0(AnimationCb callback3) {
void Klayman::spriteUpdate41F250() {
debug("Klayman::spriteUpdate41F250()");
+
+ int16 xdiff = _x4 - _x;
+
+ if (_doDeltaX) {
+ _x -= _deltaX;
+ } else {
+ _x += _deltaX;
+ }
+ _deltaX = 0;
+
+ if (_doDeltaY) {
+ _y -= _deltaY;
+ } else {
+ _y += _deltaY;
+ }
+ _deltaY = 0;
+
+ if (_flag) {
+ if (xdiff > 6)
+ _x += 6;
+ else if (xdiff < -6)
+ _x -= 6;
+ else
+ _x = _x4;
+ }
+
+ processDelta();
+
}
void Klayman::spriteUpdate41F5F0() {
debug("Klayman::spriteUpdate41F5F0()");
+
+ int16 xdiff = _x4 - _x;
+
+ if (_frameIndex == 9) {
+ if (xdiff > 26)
+ _deltaX += xdiff - 26;
+ else if (xdiff < -26)
+ _deltaX -= xdiff + 26;
+ }
+
+ if (xdiff > _deltaX)
+ xdiff = _deltaX;
+ else if (xdiff < -_deltaX)
+ xdiff = -_deltaX;
+ _deltaX = 0;
+
+ if (_x4 != _x) {
+ HitRect *hitRectPrev = _vm->_collisionMan->findHitRectAtPos(_x, _y);
+ _x += xdiff;
+ if (_field114) {
+ // TODO KlaymanSprite_sub_41CF70
+ } else {
+ HitRect *hitRectNext = _vm->_collisionMan->findHitRectAtPos(_x, _y);
+ if (hitRectNext->type == 0x5002) {
+ _y = MAX<int16>(hitRectNext->rect.y1, hitRectNext->rect.y2 - (hitRectNext->rect.x2 - _x) / 2);
+ } else if (hitRectNext->type == 0x5003) {
+ _y = MAX<int16>(hitRectNext->rect.y1, hitRectNext->rect.y2 - (_x - hitRectNext->rect.x1) / 2);
+ } else if (hitRectPrev->type == 0x5002) {
+ if (xdiff > 0) {
+ _y = hitRectPrev->rect.y2;
+ } else {
+ _y = hitRectPrev->rect.y1;
+ }
+ } else if (hitRectPrev->type == 0x5003) {
+ if (xdiff < 0) {
+ _y = hitRectPrev->rect.y2;
+ } else {
+ _y = hitRectPrev->rect.y1;
+ }
+ }
+ }
+ processDelta();
+ }
+
}
void Klayman::sub41FB40() {
@@ -549,6 +627,7 @@ void Klayman::sub41FBB0() {
}
uint32 Klayman::handleMessage41DD80(int messageNum, const MessageParam &param, Entity *sender) {
+ debug("Klayman::handleMessage41DD80(%04X)", messageNum);
uint32 messageResult = handleMessage41D360(messageNum, param, sender);
switch (messageNum) {
case 0x100D:
@@ -579,6 +658,7 @@ uint32 Klayman::handleMessage41DD80(int messageNum, const MessageParam &param, E
}
void Klayman::sub41CD70(int16 x) {
+ debug("Klayman::sub41CD70(%d)", x);
if (x > _x) {
if (ABS(x - _x) <= 105) {
debug("// TODO sub41CAC0(x);");
@@ -615,7 +695,8 @@ void Klayman::sub41FB30() {
}
uint32 Klayman::handleMessage41EC70(int messageNum, const MessageParam &param, Entity *sender) {
- uint32 messageResult = handleMessage41D360(messageNum, param, sender);
+ debug("Klayman::handleMessage41EC70(%04X)", messageNum);
+ uint32 messageResult = handleMessage41D480(messageNum, param, sender);
switch (messageNum) {
case 0x100D:
if (param.asInteger() == 0x32180101) {
@@ -654,6 +735,7 @@ void Klayman::spriteUpdate41F300() {
}
uint32 Klayman::handleMessage41EB70(int messageNum, const MessageParam &param, Entity *sender) {
+ debug("Klayman::handleMessage41EB70(%04X)", messageNum);
uint32 messageResult = handleMessage41D360(messageNum, param, sender);
switch (messageNum) {
case 0x100D:
@@ -676,15 +758,16 @@ uint32 Klayman::handleMessage41EB70(int messageNum, const MessageParam &param, E
}
void Klayman::sub41FA40() {
- if (_status == 2) {
+ if (_status3 == 2) {
sub41C7B0();
- } else if (_status == 3) {
- debug("// TODO sub420F20();");
+ } else if (_status3 == 3) {
+ debug("/////////////////////////////////////////////////// TODO sub420F20();");
// TODO sub420F20();
} else {
_flagE2 = true;
+ _flagE5 = true;
if (ABS(_x4 - _x) <= 42 && _frameIndex >= 5 && _frameIndex <= 11) {
- if (_status == 0) {
+ if (_status3 == 0) {
_status2 = 1;
setFileHash(0xF234EE31, 0, -1);
} else {
@@ -692,7 +775,7 @@ void Klayman::sub41FA40() {
setFileHash(0xF135CC21, 0, -1);
}
} else if (ABS(_x4 - _x) <= 10 && (_frameIndex >= 12 || _frameIndex <= 4)) {
- if (_status == 0) {
+ if (_status3 == 0) {
_status2 = 1;
setFileHash(0x8604A152, 0, -1);
} else {
@@ -700,7 +783,6 @@ void Klayman::sub41FA40() {
setFileHash(0xA246A132, 0, -1);
}
}
- _flagE5 = true;
SetUpdateHandler(&Klayman::update);
SetMessageHandler(&Klayman::handleMessage41DD80);
SetSpriteCallback(&Klayman::spriteUpdate41F5F0);
@@ -714,20 +796,20 @@ void Klayman::spriteUpdate41F320() {
if (xdelta > _deltaX)
xdelta = _deltaX;
- else if (xdelta < _deltaX)
+ else if (xdelta < -_deltaX)
xdelta = -_deltaX;
_deltaX = 0;
if (xdiff == 0) {
sendMessage(0x1019, 0, this);
- } else if (_status != 2 && _status != 3 && xdiff <= 42 && _frameIndex >= 5 && _frameIndex <= 11) {
+ } else if (_status3 != 2 && _status3 != 3 && xdiff <= 42 && _frameIndex >= 5 && _frameIndex <= 11) {
sendMessage(0x1019, 0, this);
- } else if (_status != 2 && _status != 3 && xdiff <= 10 && (_frameIndex >= 12 || _frameIndex <= 4)) {
+ } else if (_status3 != 2 && _status3 != 3 && xdiff <= 10 && (_frameIndex >= 12 || _frameIndex <= 4)) {
sendMessage(0x1019, 0, this);
- } else if (_status == 3 && xdiff < 30) {
+ } else if (_status3 == 3 && xdiff < 30) {
sendMessage(0x1019, 0, this);
- } else if (_status == 3 && xdiff < 150 && _frameIndex >= 6) {
+ } else if (_status3 == 3 && xdiff < 150 && _frameIndex >= 6) {
sendMessage(0x1019, 0, this);
} else {
HitRect *hitRectPrev = _vm->_collisionMan->findHitRectAtPos(_x, _y);
@@ -766,4 +848,18 @@ void Klayman::spriteUpdate41F320() {
}
+uint32 Klayman::handleMessage41E210(int messageNum, const MessageParam &param, Entity *sender) {
+ uint32 messageResult = handleMessage41D480(messageNum, param, sender);
+ switch (messageNum) {
+ case 0x100D:
+ if (param.asInteger() == 0x4AB28209) {
+ _attachedSprite->sendMessage(0x482A, 0, this);
+ } else if (param.asInteger() == 0x88001184) {
+ _attachedSprite->sendMessage(0x482B, 0, this);
+ }
+ break;
+ }
+ return messageResult;
+}
+
} // End of namespace Neverhood
diff --git a/engines/neverhood/klayman.h b/engines/neverhood/klayman.h
index 50a12ae6a4..7b65e8db60 100644
--- a/engines/neverhood/klayman.h
+++ b/engines/neverhood/klayman.h
@@ -78,7 +78,7 @@ protected:
bool _flagFA;
SoundResource _soundResource1;
SoundResource _soundResource2;
- int _status;
+ int _status3;
const KlaymanTableItem *_table;
int _tableCount;
int _tableMaxValue;
@@ -151,6 +151,8 @@ protected:
void spriteUpdate41F320();
+ uint32 handleMessage41E210(int messageNum, const MessageParam &param, Entity *sender);
+
};
} // End of namespace Neverhood
diff --git a/engines/neverhood/module.mk b/engines/neverhood/module.mk
index 2058db9e3e..eb656def42 100644
--- a/engines/neverhood/module.mk
+++ b/engines/neverhood/module.mk
@@ -5,7 +5,6 @@ MODULE_OBJS = \
blbarchive.o \
collisionman.o \
detection.o \
- entity.o \
gamemodule.o \
graphics.o \
klayman.o \
diff --git a/engines/neverhood/module1000.cpp b/engines/neverhood/module1000.cpp
index eea0d99567..c631dc0b50 100644
--- a/engines/neverhood/module1000.cpp
+++ b/engines/neverhood/module1000.cpp
@@ -152,14 +152,17 @@ uint32 KmScene1001::xHandleMessage(int messageNum, const MessageParam &param) {
}
break;
case 0x480D:
- debug("########### A");
- // TODO setCallback2(AnimationCallback(&Klayman::sub44FA50));
+ setCallback2(AnimationCallback(&KmScene1001::sub44FA50));
break;
case 0x4812:
debug("########### B");
// TODO setCallback2(AnimationCallback(&Klayman::sub41FF80));
break;
-
+ case 0x4817:
+ setDoDeltaX(param.asInteger());
+ sub41C7B0();
+ break;
+
case 0x4836:
if (param.asInteger() == 1) {
_parentScene->sendMessage(0x2002, 0, this);
@@ -169,7 +172,7 @@ uint32 KmScene1001::xHandleMessage(int messageNum, const MessageParam &param) {
case 0x4840:
sub41CD70(param.asInteger());
- break;
+ break;
}
// TODO
@@ -189,7 +192,8 @@ void KmScene1001::sub44FA50() {
}
uint32 KmScene1001::handleMessage44FA00(int messageNum, const MessageParam &param, Entity *sender) {
- uint32 messageResult = Klayman::handleMessage(messageNum, param, sender);
+ debug("KmScene1001::handleMessage44FA00(%04X)", messageNum);
+ uint32 messageResult = Klayman::handleMessage41E210(messageNum, param, sender);
switch (messageNum) {
case 0x100D:
if (param.asInteger() == 0x4AB28209) {
@@ -372,7 +376,6 @@ uint32 AsScene1001Lever::handleMessage(int messageNum, const MessageParam &param
}
break;
case 0x1011:
- debug("Click lever");
_parentScene->sendMessage(0x4826, 0, this);
messageResult = 1;
break;
@@ -531,11 +534,10 @@ uint32 Scene1001::handleMessage(int messageNum, const MessageParam &param, Entit
} else if (param.asInteger() == 0x21E64A00) {
if (_vm->getGlobalVar(0xD217189D)) {
setMessageList(0x004B48A8);
- messageResult = 1;
} else {
setMessageList(0x004B48C8);
- messageResult = 1;
}
+ messageResult = 1;
} else if (param.asInteger() == 0x040424D0) {
_klayman->sendMessage(0x1014, _ssButton, this);
} else if (param.asInteger() == 0x80006358) {
@@ -547,7 +549,6 @@ uint32 Scene1001::handleMessage(int messageNum, const MessageParam &param, Entit
}
break;
case 0x2002:
- debug("########## setRectList(0x004B49F0);");
setRectList(0x004B49F0);
break;
case 0x480B:
diff --git a/engines/neverhood/neverhood.cpp b/engines/neverhood/neverhood.cpp
index 0e3e0a33ea..9c029190cb 100644
--- a/engines/neverhood/neverhood.cpp
+++ b/engines/neverhood/neverhood.cpp
@@ -79,6 +79,11 @@ Common::Error NeverhoodEngine::run() {
_res->addArchive("t.blb");
CursorMan.showMouse(true);
+ {
+ byte buffer[2*2];
+ memset(buffer, 255, 4);
+ CursorMan.replaceCursor(buffer, 2, 2, 0, 0, 0);
+ }
#if 0
BlbArchive *blb = new BlbArchive();
@@ -143,9 +148,6 @@ Common::Error NeverhoodEngine::run() {
switch (event.type) {
case Common::EVENT_KEYDOWN:
_keyState = event.kbd.keycode;
-
- // DEBUG gameModule->sendMessage(0x480F, 0, NULL);
-
break;
case Common::EVENT_KEYUP:
_keyState = Common::KEYCODE_INVALID;
@@ -186,7 +188,7 @@ Common::Error NeverhoodEngine::run() {
_screen->wait();
_screen->update();
- //debug("---------------------------------------");
+ debug("---------------------------------------");
}
diff --git a/engines/neverhood/resource.cpp b/engines/neverhood/resource.cpp
index e3a29c573d..83078afe60 100644
--- a/engines/neverhood/resource.cpp
+++ b/engines/neverhood/resource.cpp
@@ -267,8 +267,6 @@ void AnimResource::unload() {
void AnimResource::clear() {
_resourceHandle = -1;
- // _count = 0;
- // _infoStructs = NULL;
_currSpriteData = NULL;
_fileHash = 0;
_paletteData = NULL;
diff --git a/engines/neverhood/scene.cpp b/engines/neverhood/scene.cpp
index 9d7d550c2d..9e1f06bf0f 100644
--- a/engines/neverhood/scene.cpp
+++ b/engines/neverhood/scene.cpp
@@ -180,13 +180,13 @@ void Scene::update() {
if (_smkFileHash != 0) {
// TODO
//**** ALL TODO
- //_smackerPlayer = new SmackerPlayer(this, _smkFileHash, true, 0);
+ _smackerPlayer = new SmackerPlayer(_vm, this, _smkFileHash, true, 0);
_savedUpdateHandlerCb = _updateHandlerCb;
_savedMessageHandlerCb = _messageHandlerCb;
SetUpdateHandler(&Scene::smackerUpdate);
SetMessageHandler(&Scene::smackerHandleMessage);
_smackerDone = false;
- // smackerUpdate();
+ smackerUpdate();
// g_screen->smackerPlayer = _smackerPlayer;
_smkFileHash = 0;
} else {
@@ -219,7 +219,6 @@ void Scene::update() {
}
uint32 Scene::handleMessage(int messageNum, const MessageParam &param, Entity *sender) {
- // TODO
switch (messageNum) {
case 0: // mouse moved
#if 0
@@ -348,9 +347,8 @@ bool Scene::queryPositionRectList(int16 mouseX, int16 mouseY) {
}
}
}
- return true;
}
- return false;
+ return true;
}
void Scene::setMessageList(uint32 id, bool messageListFlag, bool systemCallbackFlag) {
@@ -358,6 +356,7 @@ void Scene::setMessageList(uint32 id, bool messageListFlag, bool systemCallbackF
}
void Scene::setMessageList(MessageList *messageList, bool messageListFlag, bool systemCallbackFlag) {
+ debug("Scene::setMessageList(%p)", (void*)messageList);
_messageList = messageList;
_messageListCount = _messageList ? _messageList->size() : 0;
_messageListIndex = 0;
@@ -366,6 +365,13 @@ void Scene::setMessageList(MessageList *messageList, bool messageListFlag, bool
_systemCallbackFlag = systemCallbackFlag;
_messageListStatus = 1;
_klayman->sendMessage(0x101C, 0, this);
+
+ // DEBUG: Show message list
+ for (uint i = 0; i < messageList->size(); i++) {
+ debug("%02d: %04X, %08X", i, (*messageList)[i].messageNum, (*messageList)[i].messageValue);
+ }
+ debug("================================================================");
+
}
bool Scene::setMessageList2(uint32 id, bool messageListFlag, bool systemCallbackFlag) {
@@ -404,24 +410,19 @@ bool Scene::setMessageList2(MessageList *messageList, bool messageListFlag, bool
}
_messageList2 = messageList;
setMessageList(messageList, messageListFlag, systemCallbackFlag);
+ result = true;
}
return result;
}
void Scene::runMessageList() {
+ debug("Scene::runMessageList() _messageListFlag2 = %d; _messageListFlag1 = %d", _messageListFlag2, _messageListFlag1);
- //debug("_messageListFlag2 = %d", _messageListFlag2);
-
- if (_messageListFlag2)
+ if (_messageListFlag2 || _messageListFlag1)
return;
_messageListFlag2 = true;
- if (_messageListFlag1) {
- _messageListFlag2 = false;
- return;
- }
-
if (!_messageList) {
_messageList2 = NULL;
_messageListStatus = 0;
@@ -433,7 +434,7 @@ void Scene::runMessageList() {
int messageNum = (*_messageList)[_messageListIndex].messageNum;
uint32 messageParam = (*_messageList)[_messageListIndex].messageValue;
- debug("$$$$$$$$$$$ Scene::runMessageList() %04X, %08X", messageNum, messageParam);
+ //debug("Scene::runMessageList() %04X, %08X", messageNum, messageParam);
_messageListIndex++;
if (_messageListIndex == _messageListCount) {
diff --git a/engines/neverhood/sprite.cpp b/engines/neverhood/sprite.cpp
index d9257502a0..713bfeffe6 100644
--- a/engines/neverhood/sprite.cpp
+++ b/engines/neverhood/sprite.cpp
@@ -73,10 +73,12 @@ bool Sprite::isPointInside(int16 x, int16 y) {
}
uint32 Sprite::handleMessage(int messageNum, const MessageParam &param, Entity *sender) {
- if (messageNum == 5) {
+ switch (messageNum) {
+ case 0x0005:
// TODO: Draw debug marker (?)
// TODO g_Screen->drawLine(_x - 5, _y, _x + 6, _y);
// TODO g_Screen->drawLine(_x, _y - 5, _x, _y + 6);
+ break;
}
return 0;
}
@@ -268,14 +270,16 @@ void AnimatedSprite::updateAnim() {
if (_animResource.loadInternal(_fileHash2)) {
_fileHash3 = _fileHash2;
} else {
+ debug("TODO");
// TODO _animResource.loadInternal(calcHash("sqDefault"));
_fileHash3 = 0;
}
if (_replNewByte != _replOldByte) {
+ debug("TODO");
// TODO _animResource.setRepl(_replOldByte, _replNewByte);
}
_fileHash2 = 0;
- if (_status != 0) {
+ if (_animStatus != 0) {
_frameIndex = _fileHash6 != 0 ? MAX<int16>(0, _animResource.getFrameIndex(_fileHash6)) : 0;
_frameIndex2 = _fileHash5 != 0 ? MAX<int16>(0, _animResource.getFrameIndex(_fileHash5)) : _animResource.getFrameCount() - 1;
} else {
@@ -292,17 +296,19 @@ void AnimatedSprite::updateAnim() {
}
if (_fileHash1 != 0) {
- if (_status == 2) {
+ if (_animStatus == 2) {
_hashListIndex = _frameIndex;
} else {
- if (_status == 1) {
+ if (_animStatus == 1) {
if (_animResource.loadInternal(_fileHash1)) {
_fileHash3 = _fileHash1;
} else {
+ debug("TODO");
// TODO _animResource.loadInternal(calcHash("sqDefault"));
_fileHash3 = 0;
}
if (_replNewByte != _replOldByte) {
+ debug("TODO");
// TODO _animResource.setRepl(_replOldByte, _replNewByte);
}
_fileHash1 = 0;
@@ -312,10 +318,12 @@ void AnimatedSprite::updateAnim() {
if (_animResource.loadInternal(_fileHash1)) {
_fileHash3 = _fileHash1;
} else {
+ debug("TODO");
// TODO _animResource.loadInternal(calcHash("sqDefault"));
_fileHash3 = 0;
}
if (_replNewByte != _replOldByte) {
+ debug("TODO");
// TODO _animResource.setRepl(_replOldByte, _replNewByte);
}
_fileHash1 = 0;
@@ -419,7 +427,7 @@ void AnimatedSprite::setFileHash(uint32 fileHash, int16 frameIndex3, int16 frame
_frameIndex3 = frameIndex3;
_frameIndex4 = frameIndex4;
_fileHash4 = 0;
- _status = 0;
+ _animStatus = 0;
_playBackwards = false;
_newHashListIndex = -1;
_hashListIndex = -1;
@@ -427,7 +435,7 @@ void AnimatedSprite::setFileHash(uint32 fileHash, int16 frameIndex3, int16 frame
void AnimatedSprite::setFileHash1() {
_fileHash1 = 1;
- _status = 2;
+ _animStatus = 2;
}
void AnimatedSprite::setFileHash2(uint32 fileHash, uint32 fileHash6, uint32 fileHash5) {
@@ -435,7 +443,7 @@ void AnimatedSprite::setFileHash2(uint32 fileHash, uint32 fileHash6, uint32 file
_fileHash6 = fileHash6;
_fileHash5 = fileHash5;
_fileHash4 = 0;
- _status = 1;
+ _animStatus = 1;
_playBackwards = false;
_newHashListIndex = -1;
_hashListIndex = -1;
@@ -446,7 +454,7 @@ void AnimatedSprite::setFileHash3(uint32 fileHash2, uint32 fileHash6, uint32 fil
_fileHash6 = fileHash6;
_fileHash5 = fileHash5;
_fileHash4 = 0;
- _status = 1;
+ _animStatus = 1;
_playBackwards = false;
_newHashListIndex = -1;
_hashListIndex = -1;
@@ -456,13 +464,12 @@ void AnimatedSprite::setCallback1(AnimationCb callback1) {
if (_callback1Cb) {
(this->*_callback1Cb)();
}
- SetAnimationCallback1(callback1);
+ _callback1Cb = callback1;
}
void AnimatedSprite::setCallback2(AnimationCb callback2) {
if (_callback1Cb) {
- // _callback1Cb has to be cleared before it's called
AnimationCb cb = _callback1Cb;
_callback1Cb = NULL;
(this->*cb)();
@@ -481,7 +488,6 @@ void AnimatedSprite::setCallback2(AnimationCb callback2) {
void AnimatedSprite::removeCallbacks() {
if (_callback1Cb) {
- // _callback1Cb has to be cleared before it's called
AnimationCb cb = _callback1Cb;
_callback1Cb = NULL;
(this->*cb)();
diff --git a/engines/neverhood/sprite.h b/engines/neverhood/sprite.h
index 160bfe1a7f..16f741afaa 100644
--- a/engines/neverhood/sprite.h
+++ b/engines/neverhood/sprite.h
@@ -113,7 +113,7 @@ protected:
int16 _frameIndex4;
uint32 _fileHash6;
uint32 _fileHash5;
- int16 _status;
+ int16 _animStatus;
int16 _counter;
int _hashListIndex;
int _newHashListIndex;
@@ -143,7 +143,6 @@ protected:
void setFileHash3(uint32 fileHash2, uint32 fileHash6, uint32 fileHash5);
void setCallback1(AnimationCb callback1);
void setCallback2(AnimationCb callback2);
- int16 getHashListIndex(uint32 fileHash) { return 0; } // TODO !!!
void removeCallbacks();
};