diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/neverhood/gamemodule.cpp | 25 | ||||
-rw-r--r-- | engines/neverhood/module.cpp | 2 | ||||
-rw-r--r-- | engines/neverhood/module1500.cpp | 91 | ||||
-rw-r--r-- | engines/neverhood/module1500.h | 16 | ||||
-rw-r--r-- | engines/neverhood/neverhood.cpp | 91 | ||||
-rw-r--r-- | engines/neverhood/neverhood.h | 4 | ||||
-rw-r--r-- | engines/neverhood/resource.h | 9 | ||||
-rw-r--r-- | engines/neverhood/scene.h | 2 |
8 files changed, 186 insertions, 54 deletions
diff --git a/engines/neverhood/gamemodule.cpp b/engines/neverhood/gamemodule.cpp index 09046cfa3e..e46d23c420 100644 --- a/engines/neverhood/gamemodule.cpp +++ b/engines/neverhood/gamemodule.cpp @@ -22,20 +22,22 @@ #include "neverhood/gamemodule.h" +#include "neverhood/module1500.h" + namespace Neverhood { GameModule::GameModule(NeverhoodEngine *vm) - : Module(_vm, NULL) { + : Module(vm, NULL) { // Other initializations moved to actual engine class // TODO // TODO Sound1ChList_sub_407F70(0x2D0031, 0x8861079); - - SetMessageHandler(&GameModule::handleMessage); + + startup(); } @@ -49,6 +51,8 @@ GameModule::~GameModule() { // TODO: Set palette to black but probably not neccessary // TODO Sound1ChList_sub_408480(); + + // TODO Set debug vars (maybe) } @@ -84,15 +88,24 @@ void GameModule::startup() { } void GameModule::createModule1500(int which) { - // TODO _someFlag1 = false; // TODO *getGlobalGameVarValuePtr(0x91080831) = 0x0F10114; - // TODO _childObject = new Module1500(this, which, true); + _childObject = new Module1500(_vm, this, which, true); SetUpdateHandler(&GameModule::updateModule1500); } void GameModule::updateModule1500() { - // TODO + if (!_childObject) + return; + _childObject->handleUpdate(); + if (_done) { + _done = false; + delete _childObject; + _childObject = NULL; + debug("Done..."); + // TODO createModule1000(); + // TODO _childObject->handleUpdate(); + } } } // End of namespace Neverhood diff --git a/engines/neverhood/module.cpp b/engines/neverhood/module.cpp index 1aa1203885..c46aa79ea2 100644 --- a/engines/neverhood/module.cpp +++ b/engines/neverhood/module.cpp @@ -25,7 +25,7 @@ namespace Neverhood { Module::Module(NeverhoodEngine *vm, Module *parentModule) - : Entity(_vm, 0), _parentModule(parentModule), _childObject(NULL), + : Entity(vm, 0), _parentModule(parentModule), _childObject(NULL), _done(false), _field24(-1), _field26(-1), _field28(-1) { SetMessageHandler(&Module::handleMessage); diff --git a/engines/neverhood/module1500.cpp b/engines/neverhood/module1500.cpp index 05a3bec907..f4c77948b4 100644 --- a/engines/neverhood/module1500.cpp +++ b/engines/neverhood/module1500.cpp @@ -26,6 +26,8 @@ namespace Neverhood { Module1500::Module1500(NeverhoodEngine *vm, Module *parentModule, int which, bool flag) : Module(vm, parentModule), _flag(flag) { + + debug("Create Module1500(%d)", which); if (which < 0) { switch (_vm->gameState().sceneNum) { @@ -75,19 +77,100 @@ void Module1500::update() { } void Module1500::createScene1501() { - // TODO + debug("createScene1501"); + _vm->gameState().sceneNum = 0; + _childObject = new Scene1501(_vm, this, 0x8420221D, 0xA61024C4, 150, 48); + SetUpdateHandler(&Module1500::update); } void Module1500::createScene1502() { - // TODO + debug("createScene1502"); + _vm->gameState().sceneNum = 1; + _childObject = new Scene1501(_vm, this, 0x30050A0A, 0x58B45E58, 110, 48); + SetUpdateHandler(&Module1500::update); } void Module1500::createScene1503() { - // TODO + debug("createScene1503"); + // TODO: This uses the MultiSmackerPlayer + // Game will crash now... } void Module1500::createScene1504() { - // TODO + debug("createScene1504"); + _vm->gameState().sceneNum = 3; + _childObject = new Scene1501(_vm, this, 0x0CA04202, 0, 110, 48); + SetUpdateHandler(&Module1500::update); +} + +// Scene1501 + +Scene1501::Scene1501(NeverhoodEngine *vm, Module *parentModule, uint32 backgroundFileHash, uint32 soundFileHash, int countdown2, int countdown3) + : Scene(vm, parentModule, true), _soundResource(vm), + _countdown3(countdown3), _countdown2(countdown2), _countdown1(0), _flag(false) { + + debug("Create Scene1501(%08X, %08X, %d, %d)", backgroundFileHash, soundFileHash, countdown2, countdown3); + + SetUpdateHandler(&Scene1501::update); + SetMessageHandler(&Scene1501::handleMessage); + + _surfaceFlag = true; + + _palette = new Palette(_vm);//DUMMY! + + /* TODO + + _background = addBackground(new Class301(_vm, backgroundFileHash, 0, 0)); + + _palette = new Palette2(_vm); + _palette->usePalette(); + addEntity(_palette); + Palette2_sub_47BF00(backgroundFileHash, 0, 256, 0); + Palette2_sub_47C060(12); + + if (soundFileHash != 0) { + _soundResource.set(soundFileHash); + _soundResource.load(); + _soundResource.play(); + } + */ + +} + +void Scene1501::update() { + + Scene::update(); + + // TODO: Since these countdowns are used a lot, maybe these can be wrapped in a class/struct + // so the code gets a little cleaner. + + if (_countdown1 != 0) { + _countdown1--; + if (_countdown1 == 0) { + // TODO g_screen->clear(0); + _parentModule->sendMessage(0x1009, 0, this); + } + } else if ((_countdown2 != 0 && (--_countdown2 == 0)) || !_soundResource.isPlaying()) { + _countdown1 = 12; + _palette->startFadeToBlack(11); + } + + if (_countdown3 != 0) + _countdown3--; + + if (_countdown3 == 0 && _flag && _countdown1 == 0) { + _countdown1 = 12; + _palette->startFadeToBlack(11); + } + +} + +uint32 Scene1501::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { + uint32 messageResult = Scene::handleMessage(messageNum, param, sender); + if (messageNum == 0x0009) { + _flag = true; + } + return messageResult; } } // End of namespace Neverhood diff --git a/engines/neverhood/module1500.h b/engines/neverhood/module1500.h index d4a4310cdc..66eef59073 100644 --- a/engines/neverhood/module1500.h +++ b/engines/neverhood/module1500.h @@ -27,6 +27,9 @@ #include "neverhood/neverhood.h" #include "neverhood/module.h" +#include "neverhood/scene.h" +#include "neverhood/graphics.h" +#include "neverhood/palette.h" namespace Neverhood { @@ -42,6 +45,19 @@ protected: void createScene1504(); }; +class Scene1501 : public Scene { +public: + Scene1501(NeverhoodEngine *vm, Module *parentModule, uint32 backgroundFileHash, uint32 soundFileHash, int countdown2, int countdown3); +protected: + SoundResource _soundResource; + int _countdown1; + int _countdown2; + int _countdown3; + bool _flag; + void update(); + uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender); +}; + } // End of namespace Neverhood #endif /* NEVERHOOD_MODULE1500_H */ diff --git a/engines/neverhood/neverhood.cpp b/engines/neverhood/neverhood.cpp index 2f27fca2df..ac89a3e658 100644 --- a/engines/neverhood/neverhood.cpp +++ b/engines/neverhood/neverhood.cpp @@ -38,6 +38,7 @@ #include "neverhood/neverhood.h" #include "neverhood/blbarchive.h" +#include "neverhood/gamemodule.h" #include "neverhood/graphics.h" #include "neverhood/resourceman.h" #include "neverhood/resource.h" @@ -123,55 +124,65 @@ Common::Error NeverhoodEngine::run() { } #endif -#if 1 +#if 0 { // Create a new scope AnimResource r(this); r.load(0x000540B0); } #endif - - delete _res; - return Common::kNoError; -} + _gameModule = new GameModule(this); -void NeverhoodEngine::updateEvents() { - Common::Event event; - Common::EventManager *eventMan = _system->getEventManager(); - - while (eventMan->pollEvent(event)) { - switch (event.type) { - case Common::EVENT_KEYDOWN: - _keyState = event.kbd.keycode; - break; - case Common::EVENT_KEYUP: - _keyState = Common::KEYCODE_INVALID; - break; - case Common::EVENT_MOUSEMOVE: - _mouseX = event.mouse.x; - _mouseY = event.mouse.y; - break; - /* - case Common::EVENT_LBUTTONDOWN: - _buttonState |= kLeftButton; - break; - case Common::EVENT_LBUTTONUP: - _buttonState &= ~kLeftButton; - break; - case Common::EVENT_RBUTTONDOWN: - _buttonState |= kRightButton; - break; - case Common::EVENT_RBUTTONUP: - _buttonState &= ~kRightButton; - break; - case Common::EVENT_QUIT: - _system->quit(); - break; - */ - default: - break; + while (1) { + Common::Event event; + Common::EventManager *eventMan = _system->getEventManager(); + + while (eventMan->pollEvent(event)) { + switch (event.type) { + case Common::EVENT_KEYDOWN: + _keyState = event.kbd.keycode; + break; + case Common::EVENT_KEYUP: + _keyState = Common::KEYCODE_INVALID; + break; + case Common::EVENT_MOUSEMOVE: + _mouseX = event.mouse.x; + _mouseY = event.mouse.y; + break; + /* + case Common::EVENT_LBUTTONDOWN: + _buttonState |= kLeftButton; + break; + case Common::EVENT_LBUTTONUP: + _buttonState &= ~kLeftButton; + break; + case Common::EVENT_RBUTTONDOWN: + _buttonState |= kRightButton; + break; + case Common::EVENT_RBUTTONUP: + _buttonState &= ~kRightButton; + break; + case Common::EVENT_QUIT: + _system->quit(); + break; + */ + default: + break; + } } + + _gameModule->handleUpdate(); + _system->updateScreen(); + } + + delete _gameModule; + + delete _res; + + debug("Ok."); + + return Common::kNoError; } } // End of namespace Neverhood diff --git a/engines/neverhood/neverhood.h b/engines/neverhood/neverhood.h index 8a95b05f94..b261a087f0 100644 --- a/engines/neverhood/neverhood.h +++ b/engines/neverhood/neverhood.h @@ -44,6 +44,7 @@ enum NeverhoodGameFeatures { struct NeverhoodGameDescription; class ResourceMan; +class GameModule; struct GameState { int sceneNum; @@ -74,8 +75,7 @@ public: GameState _gameState; ResourceMan *_res; - - void updateEvents(); + GameModule *_gameModule; public: diff --git a/engines/neverhood/resource.h b/engines/neverhood/resource.h index 8cab1eb565..6a76a73a64 100644 --- a/engines/neverhood/resource.h +++ b/engines/neverhood/resource.h @@ -98,6 +98,15 @@ protected: Common::Array<AnimFrameInfo> _frames; }; +// TODO: Dummy class atm + +class SoundResource { +public: + SoundResource(NeverhoodEngine *vm) : _vm(vm) {} + bool isPlaying() const { return false; } +protected: + NeverhoodEngine *_vm; +}; } // End of namespace Neverhood diff --git a/engines/neverhood/scene.h b/engines/neverhood/scene.h index 3532a43b0b..e5a3d0ecee 100644 --- a/engines/neverhood/scene.h +++ b/engines/neverhood/scene.h @@ -71,7 +71,7 @@ protected: // TODO 00000090 playerSprite dd ? // TODO 00000094 mouseSprite dd ? Palette *_palette; - // TODO 0000009C class300 dd ? + // TODO Background *_background; bool _surfaceFlag; bool _messageListFlag; MessageListItem *_messageList2; |