diff options
author | johndoe123 | 2011-06-27 17:09:55 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-05-08 20:30:57 +0200 |
commit | 4a01a69e37633aad402cea8477d812df4391a84d (patch) | |
tree | d66823d4daa1a74549adda2c5c714ffeab2a6ab3 /engines/neverhood | |
parent | eb5ab30ce0ca0cfb58eed5a434f2252afc9718f7 (diff) | |
download | scummvm-rg350-4a01a69e37633aad402cea8477d812df4391a84d.tar.gz scummvm-rg350-4a01a69e37633aad402cea8477d812df4391a84d.tar.bz2 scummvm-rg350-4a01a69e37633aad402cea8477d812df4391a84d.zip |
NEVERHOOD: Start with Module and GameModule classes
Diffstat (limited to 'engines/neverhood')
-rw-r--r-- | engines/neverhood/entity.h | 15 | ||||
-rw-r--r-- | engines/neverhood/gamemodule.cpp | 98 | ||||
-rw-r--r-- | engines/neverhood/gamemodule.h | 56 | ||||
-rw-r--r-- | engines/neverhood/module.cpp | 75 | ||||
-rw-r--r-- | engines/neverhood/module.h | 49 | ||||
-rw-r--r-- | engines/neverhood/module.mk | 2 | ||||
-rw-r--r-- | engines/neverhood/neverhood.h | 5 |
7 files changed, 296 insertions, 4 deletions
diff --git a/engines/neverhood/entity.h b/engines/neverhood/entity.h index b7ebdd1486..0b0fc74e19 100644 --- a/engines/neverhood/entity.h +++ b/engines/neverhood/entity.h @@ -32,29 +32,36 @@ struct MessageParam { uint32 _integer; // TODO: Other types... }; + MessageParam(uint32 value) { _integer = value; } // TODO: Constructors for the param types... }; #define SetUpdateHandler(handler) _updateHandlerCb = static_cast <void (Entity::*)(void)> (handler) -#define SetMessageHandler(handler) _messageHandlerCb = static_cast <uint32 (Entity::*)(int messageNum, MessageParam ¶m, Entity *sender)> (handler) +#define SetMessageHandler(handler) _messageHandlerCb = static_cast <uint32 (Entity::*)(int messageNum, const MessageParam ¶m, Entity *sender)> (handler) class Entity { public: Entity(NeverhoodEngine *vm, int priority) : _vm(vm), _updateHandlerCb(NULL), _messageHandlerCb(NULL), _priority(priority) { } - ~Entity() { + virtual ~Entity() { + } + virtual void draw() { } void handleUpdate() { if (_updateHandlerCb) (this->*_updateHandlerCb)(); } - uint32 handleMessage(int messageNum, MessageParam ¶m, Entity *sender) { + uint32 sendMessage(int messageNum, const MessageParam ¶m, Entity *sender) { return _messageHandlerCb ? (this->*_messageHandlerCb)(messageNum, param, sender) : 0; } + // Overloaded for various message parameter types + uint32 sendMessage(int messageNum, uint32 param, Entity *sender) { + return sendMessage(messageNum, MessageParam(param), sender); + } protected: void (Entity::*_updateHandlerCb)(); - uint32 (Entity::*_messageHandlerCb)(int messageNum, MessageParam ¶m, Entity *sender); + uint32 (Entity::*_messageHandlerCb)(int messageNum, const MessageParam ¶m, Entity *sender); NeverhoodEngine *_vm; int _priority; }; diff --git a/engines/neverhood/gamemodule.cpp b/engines/neverhood/gamemodule.cpp new file mode 100644 index 0000000000..887ff3d37a --- /dev/null +++ b/engines/neverhood/gamemodule.cpp @@ -0,0 +1,98 @@ +/* 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/gamemodule.h" + +namespace Neverhood { + +GameModule::GameModule(NeverhoodEngine *vm) + : Module(_vm, NULL) { + + // Other initializations moved to actual engine class + + // TODO .text:0048AD96 + + // TODO Sound1ChList_sub_407F70(0x2D0031, 0x8861079); + + + + SetMessageHandler(&GameModule::handleMessage); + +} + +GameModule::~GameModule() { + + // TODO Sound1ChList_sub_407AF0(0x2D0031); + + delete _childObject; + _childObject = NULL; + + // TODO: Set palette to black but probably not neccessary + + // TODO Sound1ChList_sub_408480(); + +} + +uint32 GameModule::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { + uint32 messageResult = Module::handleMessage(messageNum, param, sender); + switch (messageNum) { + case 0x0800: + _someFlag1 = true; + return messageResult; + case 0x1009: + _field24 = -1; + _field26 = -1; + _field28 = -1; + _field20 = param._integer; + _done = true; + return messageResult; + case 0x100A: + _field24 = (int16)param._integer; + return messageResult; + case 0x101F: + _field2C = true; + return messageResult; + case 0x1023: + _field26 = (int16)param._integer; + return messageResult; + } + return messageResult; +} + +void GameModule::startup() { + // TODO: Displaying of error text probably not needed in ScummVM + createModule1500(0); +} + +void GameModule::createModule1500(int which) { + // TODO + _someFlag1 = false; + // TODO *getGlobalGameVarValuePtr(0x91080831) = 0x0F10114; + // TODO _childObject = new Module1500(this, which, true); + SetUpdateHandler(&GameModule::updateModule1500); +} + +void GameModule::updateModule1500() { + // TODO +} + +} // End of namespace Neverhood diff --git a/engines/neverhood/gamemodule.h b/engines/neverhood/gamemodule.h new file mode 100644 index 0000000000..6f47fb6f65 --- /dev/null +++ b/engines/neverhood/gamemodule.h @@ -0,0 +1,56 @@ +/* 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. + * + */ + +// TODO: I couldn't come up with a better name than 'Module' so far + +#ifndef NEVERHOOD_GAMEMODULE_H +#define NEVERHOOD_GAMEMODULE_H + +#include "neverhood/neverhood.h" +#include "neverhood/module.h" + +namespace Neverhood { + +class GameModule : public Module { +public: + GameModule(NeverhoodEngine *vm); + virtual ~GameModule(); +protected: + Entity *_prevChildObject; + bool _someFlag1; + bool _field2C; + uint32 _counter; + /* TODO + ResourceTable _resourceTable1; + ResourceTable _resourceTable2; + ResourceTable _resourceTable3; + ResourceTable _resourceTable4; + */ + uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender); + void startup(); + void createModule1500(int which); + void updateModule1500(); +}; + +} // End of namespace Neverhood + +#endif /* NEVERHOOD_MODULE_H */ diff --git a/engines/neverhood/module.cpp b/engines/neverhood/module.cpp new file mode 100644 index 0000000000..1aa1203885 --- /dev/null +++ b/engines/neverhood/module.cpp @@ -0,0 +1,75 @@ +/* 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/module.h" + +namespace Neverhood { + +Module::Module(NeverhoodEngine *vm, Module *parentModule) + : Entity(_vm, 0), _parentModule(parentModule), _childObject(NULL), + _done(false), _field24(-1), _field26(-1), _field28(-1) { + + SetMessageHandler(&Module::handleMessage); + +} + +Module::~Module() { + delete _childObject; +} + +void Module::draw() { + if (_childObject) + _childObject->draw(); +} + +uint32 Module::handleMessage(int messageNum, const MessageParam ¶m, Entity *sender) { + + switch (messageNum) { + case 0x0008: + if (_parentModule) + _parentModule->sendMessage(8, 0, this); + return 0; + case 0x1009: + _field24 = -1; + _field26 = -1; + _field28 = -1; + _field20 = param._integer; + _done = true; + return 0; + case 0x100A: + _field24 = (int16)param._integer; + return 0; + case 0x1023: + _field26 = (int16)param._integer; + return 0; + case 0x1024: + _field28 = (int16)param._integer; + return 0; + default: + if (_childObject && sender == _parentModule) + return _childObject->sendMessage(messageNum, param, sender); + } + + return 0; +} + +} // End of namespace Neverhood diff --git a/engines/neverhood/module.h b/engines/neverhood/module.h new file mode 100644 index 0000000000..432a04c043 --- /dev/null +++ b/engines/neverhood/module.h @@ -0,0 +1,49 @@ +/* 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. + * + */ + +// TODO: I couldn't come up with a better name than 'Module' so far + +#ifndef NEVERHOOD_MODULE_H +#define NEVERHOOD_MODULE_H + +#include "neverhood/neverhood.h" +#include "neverhood/entity.h" + +namespace Neverhood { + +class Module : public Entity { +public: + Module(NeverhoodEngine *vm, Module *parentModule); + virtual ~Module(); + virtual void draw(); +protected: + Module *_parentModule; + Entity *_childObject; + bool _done; + int16 _field24, _field26, _field28; + uint32 _field20; + uint32 handleMessage(int messageNum, const MessageParam ¶m, Entity *sender); +}; + +} // End of namespace Neverhood + +#endif /* NEVERHOOD_MODULE_H */ diff --git a/engines/neverhood/module.mk b/engines/neverhood/module.mk index d70c4a96af..ef6caba6dd 100644 --- a/engines/neverhood/module.mk +++ b/engines/neverhood/module.mk @@ -4,7 +4,9 @@ MODULE_OBJS = \ blbarchive.o \ detection.o \ entity.o \ + gamemodule.o \ graphics.o \ + module.o \ neverhood.o \ palette.o \ resource.o \ diff --git a/engines/neverhood/neverhood.h b/engines/neverhood/neverhood.h index 956880fcca..edbf165654 100644 --- a/engines/neverhood/neverhood.h +++ b/engines/neverhood/neverhood.h @@ -45,6 +45,10 @@ struct NeverhoodGameDescription; class ResourceMan; +struct GameState { + int field1; +}; + class NeverhoodEngine : public ::Engine { protected: @@ -68,6 +72,7 @@ public: Common::KeyCode _keyState; uint16 _buttonState; + GameState _gameState; ResourceMan *_res; void updateEvents(); |