aboutsummaryrefslogtreecommitdiff
path: root/engines/neverhood
diff options
context:
space:
mode:
authorjohndoe1232012-10-09 18:30:39 +0000
committerWillem Jan Palenstijn2013-05-08 20:44:40 +0200
commitfd13b546a7d2a2f63cca8ace7aa900a590f665bb (patch)
tree7807ad4e476fae139de05e91a3670867927557a3 /engines/neverhood
parent59901c5d13f59c64e4ed3174544f39b7b507b0ca (diff)
downloadscummvm-rg350-fd13b546a7d2a2f63cca8ace7aa900a590f665bb.tar.gz
scummvm-rg350-fd13b546a7d2a2f63cca8ace7aa900a590f665bb.tar.bz2
scummvm-rg350-fd13b546a7d2a2f63cca8ace7aa900a590f665bb.zip
NEVERHOOD: Rename stuff in the Scene class and clean up a little
- Try to stay close to the actual frame rate - Also use the Smacker frame rate when a video is playing to keep videos in sync with the audio
Diffstat (limited to 'engines/neverhood')
-rw-r--r--engines/neverhood/diskplayerscene.cpp8
-rw-r--r--engines/neverhood/gamemodule.cpp6
-rw-r--r--engines/neverhood/klayman.cpp1
-rw-r--r--engines/neverhood/module1200.cpp4
-rw-r--r--engines/neverhood/module1300.cpp6
-rw-r--r--engines/neverhood/module1600.cpp2
-rw-r--r--engines/neverhood/module2100.cpp4
-rw-r--r--engines/neverhood/module2200.cpp10
-rw-r--r--engines/neverhood/module2400.cpp2
-rw-r--r--engines/neverhood/module2500.cpp2
-rw-r--r--engines/neverhood/navigationscene.cpp9
-rw-r--r--engines/neverhood/scene.cpp186
-rw-r--r--engines/neverhood/scene.h57
-rw-r--r--engines/neverhood/screen.cpp11
-rw-r--r--engines/neverhood/screen.h7
-rw-r--r--engines/neverhood/smackerplayer.h1
-rw-r--r--engines/neverhood/smackerscene.cpp8
17 files changed, 160 insertions, 164 deletions
diff --git a/engines/neverhood/diskplayerscene.cpp b/engines/neverhood/diskplayerscene.cpp
index cb37a244c4..8788dcfe1d 100644
--- a/engines/neverhood/diskplayerscene.cpp
+++ b/engines/neverhood/diskplayerscene.cpp
@@ -347,10 +347,11 @@ DiskplayerScene::DiskplayerScene(NeverhoodEngine *vm, Module *parentModule, int
_class494 = new Class494(_vm);
addSprite(_class494);
- // DEBUG: Give all disks
+ // DEBUG>>>: Give all disks
for (int i = 0; i < 19; i++) {
setSubVar(0x02720344, i, 1);
}
+ // DEBUG<<<
for (int i = 0; i < 20; i++) {
_diskAvailable[i] = 0;
@@ -385,6 +386,7 @@ DiskplayerScene::DiskplayerScene(NeverhoodEngine *vm, Module *parentModule, int
addSurface(_smackerPlayer->getSurface());
_smackerPlayer->setDrawPos(154, 86);
// TODO _smackerPlayer->gotoFrame(0);
+ _vm->_screen->setSmackerDecoder(_smackerPlayer->getSmackerDecoder());
_palette->usePalette();
@@ -517,6 +519,7 @@ uint32 DiskplayerScene::handleMessage(int messageNum, const MessageParam &param,
void DiskplayerScene::stop() {
_smackerPlayer->open(0x08288103, true);
+ _vm->_screen->setSmackerDecoder(_smackerPlayer->getSmackerDecoder());
_palette->usePalette();
_playButton->release();
_updateStatus = 0;
@@ -525,6 +528,7 @@ void DiskplayerScene::stop() {
void DiskplayerScene::tuneIn() {
_smackerPlayer->open(0x900001C1, false);
+ _vm->_screen->setSmackerDecoder(_smackerPlayer->getSmackerDecoder());
_palette->usePalette();
_playButton->release();
_updateStatus = 1;
@@ -533,6 +537,7 @@ void DiskplayerScene::tuneIn() {
void DiskplayerScene::playDisk() {
_smackerPlayer->open(kDiskplayerSmackerFileHashes[_diskIndex], false);
+ _vm->_screen->setSmackerDecoder(_smackerPlayer->getSmackerDecoder());
_palette->usePalette();
_updateStatus = 2;
_diskSlots[_diskIndex]->play();
@@ -540,6 +545,7 @@ void DiskplayerScene::playDisk() {
void DiskplayerScene::playStatic() {
_smackerPlayer->open(0x90000101, false);
+ _vm->_screen->setSmackerDecoder(_smackerPlayer->getSmackerDecoder());
_palette->usePalette();
_playButton->release();
_updateStatus = 2;
diff --git a/engines/neverhood/gamemodule.cpp b/engines/neverhood/gamemodule.cpp
index 8c5e3693b8..e35e16e93a 100644
--- a/engines/neverhood/gamemodule.cpp
+++ b/engines/neverhood/gamemodule.cpp
@@ -300,18 +300,20 @@ void GameModule::startup() {
// createModule(1500, 0); // Logos and intro video //Real
// DEBUG>>>
+ /*
setGlobalVar(0x0A310817, 1);
setGlobalVar(0x0A18CA33, 0);
setGlobalVar(0x0112090A, 0);
//setGlobalVar(0x000CF819, 1);
setGlobalVar(0x04A105B3, 2);
+ */
// <<<DEBUG
#if 1
_vm->gameState().which = 0;
- _vm->gameState().sceneNum = 8;
- createModule(3000, -1);
+ _vm->gameState().sceneNum = 0;
+ createModule(1200, -1);
#endif
#if 0
_vm->gameState().sceneNum = 0;
diff --git a/engines/neverhood/klayman.cpp b/engines/neverhood/klayman.cpp
index ee4bfe1b82..7343b0a120 100644
--- a/engines/neverhood/klayman.cpp
+++ b/engines/neverhood/klayman.cpp
@@ -480,6 +480,7 @@ void Klayman::gotoNextStateExt() {
removeCallbackList();
#endif
} else {
+ // Inform the scene that the current Klayman animation sequence has finished
sendMessage(_parentScene, 0x1006, 0);
}
}
diff --git a/engines/neverhood/module1200.cpp b/engines/neverhood/module1200.cpp
index 191789d723..a20ed94cd0 100644
--- a/engines/neverhood/module1200.cpp
+++ b/engines/neverhood/module1200.cpp
@@ -916,7 +916,7 @@ uint32 Scene1201::handleMessage(int messageNum, const MessageParam &param, Entit
} else if (param.asInteger() == 0x140E5744) {
sendMessage(_asCreature, 0x2005, 0);
} else if (param.asInteger() == 0x40253C40) {
- _messageListFlag = false;
+ _canAcceptInput = false;
sendMessage(_asCreature, 0x2006, 0);
} else if (param.asInteger() == 0x090EB048) {
if (_klayman->getX() < 572) {
@@ -950,7 +950,7 @@ uint32 Scene1201::handleMessage(int messageNum, const MessageParam &param, Entit
}
break;
case 0x4814:
- messageList402220();
+ cancelMessageList();
break;
case 0x4826:
if (sender == _asTape) {
diff --git a/engines/neverhood/module1300.cpp b/engines/neverhood/module1300.cpp
index 80a210bc3a..f38583576a 100644
--- a/engines/neverhood/module1300.cpp
+++ b/engines/neverhood/module1300.cpp
@@ -487,13 +487,13 @@ uint32 Scene1302::handleMessage(int messageNum, const MessageParam &param, Entit
if (getGlobalVar(0x13206309)) {
setMessageList2(0x004B0910);
} else {
- messageList402220();
+ cancelMessageList();
}
} else if (param.asInteger() == 0x012E2070) {
if (getGlobalVar(0x13206309)) {
setMessageList2(0x004B0968);
} else {
- messageList402220();
+ cancelMessageList();
}
} else if (param.asInteger() == 0x11C40840) {
if (_asVenusFlyTrap->getX() >= 260 && _asVenusFlyTrap->getX() <= 342) {
@@ -740,7 +740,7 @@ uint32 Scene1304::handleMessage(int messageNum, const MessageParam &param, Entit
case 0x100D:
if (param.asInteger() == 0x415634A4) {
if (getGlobalVar(0xAC00C0D0)) {
- messageList402220();
+ cancelMessageList();
} else {
setMessageList(0x004B9158);
}
diff --git a/engines/neverhood/module1600.cpp b/engines/neverhood/module1600.cpp
index 114bc3e65c..5d0207b133 100644
--- a/engines/neverhood/module1600.cpp
+++ b/engines/neverhood/module1600.cpp
@@ -1271,7 +1271,7 @@ void Scene1608::upGettingOutOfCar() {
_asIdleCarFull->setVisible(true);
_asCar->setVisible(false);
setMessageList(0x004B4748);
- runMessageList();
+ processMessageList();
_klayman->handleUpdate();
_carStatus = 0;
}
diff --git a/engines/neverhood/module2100.cpp b/engines/neverhood/module2100.cpp
index 06806c7ca1..44ef868adb 100644
--- a/engines/neverhood/module2100.cpp
+++ b/engines/neverhood/module2100.cpp
@@ -274,7 +274,7 @@ void Scene2101::update() {
}
} else {
if (_klayman->getX() > 575)
- _messageListFlag = false;
+ _canAcceptInput = false;
if (--_countdown1 == 0) {
if (_klayman->getX() < 480) {
sendMessage(_asDoor, 0x4809, 0);
@@ -307,7 +307,7 @@ uint32 Scene2101::handleMessage(int messageNum, const MessageParam &param, Entit
setMessageList(0x004B8EC8);
}
} else if (param.asInteger() == 0x41442820) {
- messageList402220();
+ cancelMessageList();
}
break;
case 0x2000:
diff --git a/engines/neverhood/module2200.cpp b/engines/neverhood/module2200.cpp
index 2220fb7729..777b84828e 100644
--- a/engines/neverhood/module2200.cpp
+++ b/engines/neverhood/module2200.cpp
@@ -2116,16 +2116,16 @@ uint32 Scene2207::handleMessage(int messageNum, const MessageParam &param, Entit
sendEntityMessage(_klayman, 0x1014, _asElevator);
sendMessage(_klayman, 0x2001, 0);
} else {
- messageList402220();
+ cancelMessageList();
}
} else if (param.asInteger() == 0x34569073) {
if (_klaymanAtElevator) {
- _messageListFlag1 = true;
+ _isKlaymanBusy = true;
sendMessage(_asElevator, 0x2000, 0);
sendEntityMessage(_klayman, 0x1014, _asElevator);
sendMessage(_klayman, 0x2001, 0);
} else {
- messageList402220();
+ cancelMessageList();
}
} else if (param.asInteger() == 0x4054C877) {
if (_klaymanAtElevator) {
@@ -2133,7 +2133,7 @@ uint32 Scene2207::handleMessage(int messageNum, const MessageParam &param, Entit
sendEntityMessage(_klayman, 0x1014, _asElevator);
sendMessage(_klayman, 0x2001, 0);
} else {
- messageList402220();
+ cancelMessageList();
}
} else if (param.asInteger() == 0x0CBC6211) {
sendEntityMessage(_klayman, 0x1014, _asElevator);
@@ -2153,7 +2153,7 @@ uint32 Scene2207::handleMessage(int messageNum, const MessageParam &param, Entit
_elevatorSurfacePriority = param.asInteger();
break;
case 0x2003:
- _messageListFlag1 = false;
+ _isKlaymanBusy = false;
break;
case 0x4807:
sendMessage(_asWallRobotAnimation, 0x2007, 0);
diff --git a/engines/neverhood/module2400.cpp b/engines/neverhood/module2400.cpp
index 3b6c6bb8cf..238768c557 100644
--- a/engines/neverhood/module2400.cpp
+++ b/engines/neverhood/module2400.cpp
@@ -517,7 +517,7 @@ uint32 Scene2401::handleMessage(int messageNum, const MessageParam &param, Entit
setSurfacePriority(_sprite1->getSurface(), 1100);
} else if (param.asInteger() == 0x80C40322) {
setSurfacePriority(_sprite1->getSurface(), 200);
- messageList402220();
+ cancelMessageList();
_flag = true;
} else if (param.asInteger() == 0x09C4B40A && _countdown2 > 12) {
_countdown2 = 12;
diff --git a/engines/neverhood/module2500.cpp b/engines/neverhood/module2500.cpp
index f8053d2482..b4d39d9e1d 100644
--- a/engines/neverhood/module2500.cpp
+++ b/engines/neverhood/module2500.cpp
@@ -362,7 +362,7 @@ void Scene2501::upGettingOutOfCar() {
_asIdleCarFull->setVisible(true);
_asCar->setVisible(false);
setMessageList(0x004B2570);
- runMessageList();
+ processMessageList();
_klayman->handleUpdate();
_carStatus = 0;
}
diff --git a/engines/neverhood/navigationscene.cpp b/engines/neverhood/navigationscene.cpp
index 66b30cf79e..5594cce8da 100644
--- a/engines/neverhood/navigationscene.cpp
+++ b/engines/neverhood/navigationscene.cpp
@@ -51,10 +51,11 @@ NavigationScene::NavigationScene(NeverhoodEngine *vm, Module *parentModule, uint
_smackerPlayer = new SmackerPlayer(_vm, this, (*_navigationList)[_navigationIndex].fileHash, true, true);
addEntity(_smackerPlayer);
addSurface(_smackerPlayer->getSurface());
-
+
createMouseCursor();
_vm->_screen->clear();
+ _vm->_screen->setSmackerDecoder(_smackerPlayer->getSmackerDecoder());
sendMessage(_parentModule, 0x100A, _navigationIndex);
@@ -77,10 +78,12 @@ void NavigationScene::update() {
showMouse(false);
_smackerPlayer->open(_smackerFileHash, false);
_vm->_screen->clear();
+ _vm->_screen->setSmackerDecoder(_smackerPlayer->getSmackerDecoder());
_smackerDone = false;
_smackerFileHash = 0;
} else if (_smackerDone) {
if (_leaveSceneAfter) {
+ _vm->_screen->setSmackerDecoder(NULL);
sendMessage(_parentModule, 0x1009, _navigationIndex);
} else {
const NavigationItem &navigationItem = (*_navigationList)[_navigationIndex];
@@ -94,6 +97,7 @@ void NavigationScene::update() {
_smackerDone = false;
_smackerPlayer->open(navigationItem.fileHash, true);
_vm->_screen->clear();
+ _vm->_screen->setSmackerDecoder(_smackerPlayer->getSmackerDecoder());
sendMessage(_parentModule, 0x100A, _navigationIndex);
}
}
@@ -171,6 +175,7 @@ void NavigationScene::handleNavigation(const NPoint &mousePos) {
} while (!(*_navigationList)[_navigationIndex].interactive);
setGlobalVar(0x4200189E, _navigationIndex);
} else {
+ _vm->_screen->setSmackerDecoder(NULL);
sendMessage(_parentModule, 0x1009, _navigationIndex);
}
break;
@@ -187,6 +192,7 @@ void NavigationScene::handleNavigation(const NPoint &mousePos) {
} while (!(*_navigationList)[_navigationIndex].interactive);
setGlobalVar(0x4200189E, _navigationIndex);
} else {
+ _vm->_screen->setSmackerDecoder(NULL);
sendMessage(_parentModule, 0x1009, _navigationIndex);
}
break;
@@ -194,6 +200,7 @@ void NavigationScene::handleNavigation(const NPoint &mousePos) {
case 3:
case 4:
if (navigationItem.middleFlag) {
+ _vm->_screen->setSmackerDecoder(NULL);
sendMessage(_parentModule, 0x1009, _navigationIndex);
} else if (navigationItem.middleSmackerFileHash != 0) {
_smackerFileHash = navigationItem.middleSmackerFileHash;
diff --git a/engines/neverhood/scene.cpp b/engines/neverhood/scene.cpp
index dde437dc62..318a0df10a 100644
--- a/engines/neverhood/scene.cpp
+++ b/engines/neverhood/scene.cpp
@@ -28,7 +28,7 @@ namespace Neverhood {
Scene::Scene(NeverhoodEngine *vm, Module *parentModule, bool clearHitRects)
: Entity(vm, 0), _parentModule(parentModule), _dataResource(vm) {
- _messageListFlag1 = false;
+ _isKlaymanBusy = false;
_systemCallbackFlag = false;
_messageList = NULL;
_rectType = 0;
@@ -40,22 +40,18 @@ Scene::Scene(NeverhoodEngine *vm, Module *parentModule, bool clearHitRects)
_mouseCursor = NULL;
_palette = NULL;
_background = NULL;
- // TODO _field_8E = -1;
if (clearHitRects) {
_vm->_collisionMan->clearHitRects();
_vm->_collisionMan->clearSprites();
}
_vm->_screen->setFps(24);
- // TODO g_screen->hSmack = NULL;
- // TODO g_screen->field_24 = 0;
- // TODO g_screen->field_26 = 0;
+ _vm->_screen->setSmackerDecoder(NULL);
// TODO g_screen->resetDirtyRects();
- _messageListFlag = true;
+ _canAcceptInput = true;
_surfaceFlag = false;
_messageList2 = NULL;
_smackerPlayer = NULL;
- _smkFileHash = 0;
- _messageListFlag2 = false;
+ _isMessageListBusy = false;
_messageValue = -1;
SetUpdateHandler(&Scene::update);
@@ -96,7 +92,6 @@ void Scene::draw() {
}
#endif
for (Common::Array<BaseSurface*>::iterator iter = _surfaces.begin(); iter != _surfaces.end(); iter++) {
- //debug(4, "priority = %d", (*iter)->getPriority());
(*iter)->draw();
}
}
@@ -244,43 +239,29 @@ SmackerPlayer *Scene::addSmackerPlayer(SmackerPlayer *smackerPlayer) {
void Scene::update() {
- if (_smkFileHash != 0) {
- // TODO
- _smackerPlayer = new SmackerPlayer(_vm, this, _smkFileHash, true, 0);
- _savedUpdateHandlerCb = _updateHandlerCb;
- _savedMessageHandlerCb = _messageHandlerCb;
- SetUpdateHandler(&Scene::smackerUpdate);
- SetMessageHandler(&Scene::smackerHandleMessage);
- _smackerDone = false;
- smackerUpdate();
- // g_screen->smackerPlayer = _smackerPlayer;
- _smkFileHash = 0;
- } else {
- if (_mouseClicked) {
- if (_klayman) {
- // TODO: Merge later
- if (_messageListFlag &&
- _klayman->hasMessageHandler() &&
- sendMessage(_klayman, 0x1008, 0) != 0 &&
- queryPositionSprite(_mouseClickPos.x, _mouseClickPos.y)) {
- _mouseClicked = false;
- } else if (_messageListFlag &&
- _klayman->hasMessageHandler() &&
- sendMessage(_klayman, 0x1008, 0) != 0) {
- _mouseClicked = !queryPositionRectList(_mouseClickPos.x, _mouseClickPos.y);
- }
- } else if (queryPositionSprite(_mouseClickPos.x, _mouseClickPos.y)) {
+ if (_mouseClicked) {
+ if (_klayman) {
+ // TODO: Merge later
+ if (_canAcceptInput &&
+ _klayman->hasMessageHandler() &&
+ sendMessage(_klayman, 0x1008, 0) != 0 &&
+ queryPositionSprite(_mouseClickPos.x, _mouseClickPos.y)) {
_mouseClicked = false;
+ } else if (_canAcceptInput &&
+ _klayman->hasMessageHandler() &&
+ sendMessage(_klayman, 0x1008, 0) != 0) {
+ _mouseClicked = !queryPositionRectList(_mouseClickPos.x, _mouseClickPos.y);
}
+ } else if (queryPositionSprite(_mouseClickPos.x, _mouseClickPos.y)) {
+ _mouseClicked = false;
}
+ }
- runMessageList();
+ processMessageList();
- // Update all entities
- for (Common::Array<Entity*>::iterator iter = _entities.begin(); iter != _entities.end(); iter++)
- (*iter)->handleUpdate();
-
- }
+ // Update all entities
+ for (Common::Array<Entity*>::iterator iter = _entities.begin(); iter != _entities.end(); iter++)
+ (*iter)->handleUpdate();
}
@@ -293,7 +274,7 @@ uint32 Scene::handleMessage(int messageNum, const MessageParam &param, Entity *s
case 0: // mouse moved
if (_mouseCursor && _mouseCursor->hasMessageHandler())
sendMessage(_mouseCursor, 0x4002, param);
- // TODO queryPositionSomeRects(param.asPoint().x, param.asPoint().y);
+ // TODO Seems unused: queryPositionSomeRects(param.asPoint().x, param.asPoint().y);
break;
case 1: // mouse clicked
_mouseClicked = true;
@@ -309,44 +290,53 @@ uint32 Scene::handleMessage(int messageNum, const MessageParam &param, Entity *s
drawRectListRects();
break;
*/
+ /* ORIGINAL DEBUG
case 5:
-#if 0
broadcastObjectMessage5();
-#endif
break;
+ */
case 6:
sendMessage(_parentModule, 0x1009, param);
break;
case 0x1006:
- if (_messageListFlag1) {
- _messageListFlag1 = false;
- if (_messageListIndex == _messageListCount)
+ // Sent by Klayman when its animation sequence has finished
+ if (_isKlaymanBusy) {
+ _isKlaymanBusy = false;
+ if (_messageListIndex == _messageListCount) {
+ // If the current message list was processed completely,
+ // sent Klayman into the idle state.
sendMessage(_klayman, 0x4004, 0);
- else {
- runMessageList();
+ } else {
+ // Else continue with the next message in the current message list
+ processMessageList();
}
}
break;
case 0x1007:
- if (_messageListFlag1) {
- _messageListFlag1 = false;
+ // This isn't sent by any code, check if it's in a message list
+ // This cancels the current message list and sets Klayman into the idle state.
+ if (_isKlaymanBusy) {
+ _isKlaymanBusy = false;
_messageList = NULL;
sendMessage(_klayman, 0x4004, 0);
}
break;
case 0x101D:
+ // Hide the mouse cursor
if (_mouseCursor) {
- _prevVisible = _mouseCursor->getSurface()->getVisible();
+ _mouseCursorWasVisible = _mouseCursor->getSurface()->getVisible();
_mouseCursor->getSurface()->setVisible(false);
}
break;
case 0x101E:
- if (_prevVisible && _mouseCursor) {
- _mouseCursor->getSurface()->setVisible(false);
+ // Show the mouse cursor
+ if (_mouseCursorWasVisible && _mouseCursor) {
+ _mouseCursor->getSurface()->setVisible(true);//CHECKME?!?
// TODO sendMessage(_mouseCursor, 0x4002, g_Screen->_mousePos);
}
break;
case 0x1022:
+ // Set the sender's surface priority
setSurfacePriority(((Sprite*)sender)->getSurface(), param.asInteger());
break;
}
@@ -416,17 +406,17 @@ bool Scene::queryPositionRectList(int16 mouseX, int16 mouseY) {
return true;
}
-void Scene::setMessageList(uint32 id, bool messageListFlag, bool systemCallbackFlag) {
- setMessageList(_vm->_staticData->getMessageList(id), messageListFlag, systemCallbackFlag);
+void Scene::setMessageList(uint32 id, bool canAcceptInput, bool systemCallbackFlag) {
+ setMessageList(_vm->_staticData->getMessageList(id), canAcceptInput, systemCallbackFlag);
}
-void Scene::setMessageList(MessageList *messageList, bool messageListFlag, bool systemCallbackFlag) {
+void Scene::setMessageList(MessageList *messageList, bool canAcceptInput, bool systemCallbackFlag) {
//debug("Scene::setMessageList(%p)", (void*)messageList);
_messageList = messageList;
_messageListCount = _messageList ? _messageList->size() : 0;
_messageListIndex = 0;
- _messageListFlag1 = false;
- _messageListFlag = messageListFlag;
+ _isKlaymanBusy = false;
+ _canAcceptInput = canAcceptInput;
_systemCallbackFlag = systemCallbackFlag;
_messageListStatus = 1;
sendMessage(_klayman, 0x101C, 0);
@@ -441,13 +431,11 @@ void Scene::setMessageList(MessageList *messageList, bool messageListFlag, bool
}
-bool Scene::setMessageList2(uint32 id, bool messageListFlag, bool systemCallbackFlag) {
- return setMessageList2(_vm->_staticData->getMessageList(id), messageListFlag, systemCallbackFlag);
+bool Scene::setMessageList2(uint32 id, bool canAcceptInput, bool systemCallbackFlag) {
+ return setMessageList2(_vm->_staticData->getMessageList(id), canAcceptInput, systemCallbackFlag);
}
-bool Scene::setMessageList2(MessageList *messageList, bool messageListFlag, bool systemCallbackFlag) {
- bool result = false;
-
+bool Scene::setMessageList2(MessageList *messageList, bool canAcceptInput, bool systemCallbackFlag) {
//debug("Scene::setMessageList2(%p)", (void*)messageList);
#if 0
@@ -457,46 +445,26 @@ bool Scene::setMessageList2(MessageList *messageList, bool messageListFlag, bool
}
debug("B: ================================================================");
#endif
-
- if (_messageListStatus == 1) {
- if (messageList != _messageList2) {
- if (_messageValue >= 0) {
- sendMessage(_parentModule, 0x1023, _messageValue);
- _messageValue = -1;
- }
- _messageList2 = messageList;
- setMessageList(messageList, messageListFlag, systemCallbackFlag);
- result = true;
- }
- } else if (_messageListStatus == 2) {
- if (messageList == _messageList2) {
- if (_messageValue >= 0) {
- sendMessage(_parentModule, 0x1023, _messageValue);
- _messageValue = -1;
- }
- _messageList2 = messageList;
- setMessageList(messageList, messageListFlag, systemCallbackFlag);
- result = true;
- }
- } else {
- if (_messageValue >= 0) {
- sendMessage(_parentModule, 0x1023, _messageValue);
- _messageValue = -1;
- }
+
+ if (_messageListStatus == 0 ||
+ (_messageListStatus == 1 && messageList != _messageList2) ||
+ (_messageListStatus == 2 && messageList == _messageList2)) {
+ // NOTE Skipped unneeded resource preloading code
+ _messageValue = -1;
_messageList2 = messageList;
- setMessageList(messageList, messageListFlag, systemCallbackFlag);
- result = true;
+ setMessageList(messageList, canAcceptInput, systemCallbackFlag);
+ return true;
}
- return result;
+ return false;
}
-void Scene::runMessageList() {
- debug(7, "Scene::runMessageList() _messageListFlag2 = %d; _messageListFlag1 = %d", _messageListFlag2, _messageListFlag1);
+void Scene::processMessageList() {
+ debug(7, "Scene::processMessageList() _isMessageListBusy = %d; _isKlaymanBusy = %d", _isMessageListBusy, _isKlaymanBusy);
- if (_messageListFlag2 || _messageListFlag1)
+ if (_isMessageListBusy || _isKlaymanBusy)
return;
- _messageListFlag2 = true;
+ _isMessageListBusy = true;
if (!_messageList) {
_messageList2 = NULL;
@@ -505,11 +473,11 @@ void Scene::runMessageList() {
if (_messageList && _klayman) {
- while (_messageList && _messageListIndex < _messageListCount && !_messageListFlag1) {
+ while (_messageList && _messageListIndex < _messageListCount && !_isKlaymanBusy) {
uint32 messageNum = (*_messageList)[_messageListIndex].messageNum;
uint32 messageParam = (*_messageList)[_messageListIndex].messageValue;
- //debug("Scene::runMessageList() %04X, %08X", messageNum, messageParam);
+ //debug("Scene::processMessageList() %04X, %08X", messageNum, messageParam);
_messageListIndex++;
if (_messageListIndex == _messageListCount) {
@@ -525,7 +493,7 @@ void Scene::runMessageList() {
_messageValue = messageParam;
sendMessage(_parentModule, messageNum, messageParam);
} else if (messageNum == 0x4001) {
- _messageListFlag1 = true;
+ _isKlaymanBusy = true;
sendPointMessage(_klayman, 0x4001, _mouseClickPos);
} else if (messageNum == 0x100D) {
if (this->hasMessageHandler() && sendMessage(this, 0x100D, messageParam) != 0)
@@ -535,34 +503,34 @@ void Scene::runMessageList() {
} else if (messageNum == 0x101B) {
_messageListStatus = 2;
} else if (messageNum == 0x1020) {
- _messageListFlag = false;
+ _canAcceptInput = false;
} else if (messageNum >= 0x2000 && messageNum <= 0x2FFF) {
if (this->hasMessageHandler() && sendMessage(this, messageNum, messageParam) != 0) {
- _messageListFlag2 = false;
+ _isMessageListBusy = false;
return;
}
} else {
- _messageListFlag1 = true;
+ _isKlaymanBusy = true;
if (_klayman->hasMessageHandler() && sendMessage(_klayman, messageNum, messageParam) != 0) {
- _messageListFlag1 = false;
+ _isKlaymanBusy = false;
}
}
}
if (_messageListIndex == _messageListCount) {
- _messageListFlag = true;
+ _canAcceptInput = true;
_messageList = NULL;
}
}
}
- _messageListFlag2 = false;
+ _isMessageListBusy = false;
}
-void Scene::messageList402220() {
- _messageListFlag1 = false;
+void Scene::cancelMessageList() {
+ _isKlaymanBusy = false;
_messageList = NULL;
- _messageListFlag = true;
+ _canAcceptInput = true;
sendMessage(_klayman, 0x4004, 0);
}
diff --git a/engines/neverhood/scene.h b/engines/neverhood/scene.h
index 35adb44ee8..a0f7dafd25 100644
--- a/engines/neverhood/scene.h
+++ b/engines/neverhood/scene.h
@@ -159,54 +159,55 @@ protected:
Module *_parentModule;
Common::Array<Entity*> _entities;
Common::Array<BaseSurface*> _surfaces;
- bool _systemCallbackFlag;
+
+ bool _surfaceFlag;
+
+ Klayman *_klayman;
+ Background *_background;
+ Palette *_palette;
+ SmackerPlayer *_smackerPlayer;
+
MessageList *_messageList;
+ MessageList *_messageList2;
+ int _messageListStatus;
uint _messageListCount;
uint _messageListIndex;
- bool _messageListFlag1;
+ bool _systemCallbackFlag;
+
+ bool _canAcceptInput;
+ bool _isKlaymanBusy;
+ bool _isMessageListBusy;
+
+ Mouse *_mouseCursor;
NPoint _mouseClickPos;
bool _mouseClicked;
- DataResource _dataResource;
+ bool _mouseCursorWasVisible;
+
+ int _rectType;
RectList *_rectList;
+ DataResource _dataResource;
+
HitRectList _hitRectList;
- int _rectType;
- // TODO 0000008E field_8E dw ?
- Mouse *_mouseCursor;
- Klayman *_klayman;
- Palette *_palette;
- Background *_background;
- bool _surfaceFlag;
- bool _messageListFlag;
- MessageList *_messageList2;
- int _messageListStatus;
- SmackerPlayer *_smackerPlayer;
+
void (Entity::*_savedUpdateHandlerCb)();
uint32 (Entity::*_savedMessageHandlerCb)(int messageNum, const MessageParam &param, Entity *sender);
bool _smackerDone;
- // TODO 000000BD field_BD db ?
- // TODO 000000BE field_BE db ?
- // TODO 000000BF field_BF db ?
- uint32 _smkFileHash;
- // TODO 000000C4 hitArray dd ?
- bool _messageListFlag2;
- bool _prevVisible;
int _messageValue;
- // TODO 000000CF field_CF db ?
uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
void smackerUpdate();
uint32 smackerHandleMessage(int messageNum, const MessageParam &param, Entity *sender);
bool queryPositionSprite(int16 mouseX, int16 mouseY);
bool queryPositionRectList(int16 mouseX, int16 mouseY);
- void setMessageList(uint32 id, bool messageListFlag = true, bool systemCallbackFlag = false);
- void setMessageList(MessageList *messageList, bool messageListFlag = true, bool systemCallbackFlag = false);
- bool setMessageList2(uint32 id, bool messageListFlag = true, bool systemCallbackFlag = false);
- bool setMessageList2(MessageList *messageList, bool messageListFlag = true, bool systemCallbackFlag = false);
- void runMessageList();
+ void setMessageList(uint32 id, bool canAcceptInput = true, bool systemCallbackFlag = false);
+ void setMessageList(MessageList *messageList, bool canAcceptInput = true, bool systemCallbackFlag = false);
+ bool setMessageList2(uint32 id, bool canAcceptInput = true, bool systemCallbackFlag = false);
+ bool setMessageList2(MessageList *messageList, bool canAcceptInput = true, bool systemCallbackFlag = false);
+ void processMessageList();
void setRectList(uint32 id);
void setRectList(RectList *rectList);
void clearRectList();
void loadHitRectList();
- void messageList402220();
+ void cancelMessageList();
void loadDataResource(uint32 fileHash);
uint16 convertMessageNum(uint32 messageNum);
};
diff --git a/engines/neverhood/screen.cpp b/engines/neverhood/screen.cpp
index 372c705b3e..4689d3ba2d 100644
--- a/engines/neverhood/screen.cpp
+++ b/engines/neverhood/screen.cpp
@@ -26,7 +26,7 @@
namespace Neverhood {
Screen::Screen(NeverhoodEngine *vm)
- : _vm(vm), _paletteData(NULL), _paletteChanged(false) {
+ : _vm(vm), _paletteData(NULL), _paletteChanged(false), _smackerDecoder(NULL) {
_ticks = _vm->_system->getMillis();
@@ -48,8 +48,13 @@ void Screen::update() {
}
void Screen::wait() {
- // TODO
- _vm->_system->delayMillis(40);
+ int32 frameDelay = _frameDelay;
+ if (_smackerDecoder && _smackerDecoder->isVideoLoaded() && !_smackerDecoder->endOfVideo())
+ frameDelay = _smackerDecoder->getTimeToNextFrame();
+ int32 waitTicks = frameDelay - (_vm->_system->getMillis() - _ticks);
+ if (waitTicks > 0)
+ _vm->_system->delayMillis(waitTicks);
+ _ticks = _vm->_system->getMillis();
}
void Screen::setFps(int fps) {
diff --git a/engines/neverhood/screen.h b/engines/neverhood/screen.h
index fe5a2546c0..56a256757c 100644
--- a/engines/neverhood/screen.h
+++ b/engines/neverhood/screen.h
@@ -24,6 +24,7 @@
#define NEVERHOOD_SCREEN_H
#include "graphics/surface.h"
+#include "video/smk_decoder.h"
#include "neverhood/neverhood.h"
#include "neverhood/graphics.h"
@@ -51,11 +52,13 @@ public:
void drawDoubleSurface2(const Graphics::Surface *surface, NDrawRect &drawRect);
void drawUnk(const Graphics::Surface *surface, NDrawRect &drawRect, NDrawRect &sysRect, NRect &clipRect, bool transparent);
void drawSurfaceClipRects(const Graphics::Surface *surface, NDrawRect &drawRect, NRect *clipRects, uint clipRectsCount, bool transparent);
+ void setSmackerDecoder(Video::SmackerDecoder *smackerDecoder) { _smackerDecoder = smackerDecoder; }
protected:
NeverhoodEngine *_vm;
Graphics::Surface *_backScreen;
- uint32 _ticks;
- uint32 _frameDelay;
+ Video::SmackerDecoder *_smackerDecoder;
+ int32 _ticks;
+ int32 _frameDelay;
byte *_paletteData;
bool _paletteChanged;
};
diff --git a/engines/neverhood/smackerplayer.h b/engines/neverhood/smackerplayer.h
index 65c0c84e11..697893d8c5 100644
--- a/engines/neverhood/smackerplayer.h
+++ b/engines/neverhood/smackerplayer.h
@@ -60,6 +60,7 @@ public:
uint getStatus();
void setDrawPos(int16 x, int16 y);
void rewind();
+ Video::SmackerDecoder *getSmackerDecoder() const { return _smackerDecoder; }
protected:
Scene *_scene;
Palette *_palette;
diff --git a/engines/neverhood/smackerscene.cpp b/engines/neverhood/smackerscene.cpp
index 9982043dea..375f7f3aa8 100644
--- a/engines/neverhood/smackerscene.cpp
+++ b/engines/neverhood/smackerscene.cpp
@@ -73,6 +73,7 @@ void SmackerScene::nextVideo() {
uint32 smackerFileHash = _fileHashList[_fileHashListIndex];
if (_vm->_res->getResourceTypeByHash(smackerFileHash) != 10) {
// Not a Smacker file
+ _vm->_screen->setSmackerDecoder(NULL);
sendMessage(_parentModule, 0x1009, 0);
return;
}
@@ -80,12 +81,13 @@ void SmackerScene::nextVideo() {
if (!_fieldDF) {
setSubVar(0x00800410, smackerFileHash, 1);
}
- if (_fileHashListIndex == 0) {
+ if (_fileHashListIndex == 0)
_smackerPlayer = addSmackerPlayer(new SmackerPlayer(_vm, this, smackerFileHash, _doubleSurface, false));
- } else {
+ else
_smackerPlayer->open(smackerFileHash, false);
- }
+ _vm->_screen->setSmackerDecoder(_smackerPlayer->getSmackerDecoder());
} else {
+ _vm->_screen->setSmackerDecoder(NULL);
sendMessage(_parentModule, 0x1009, 0);
}