NEVERHOOD: More work on Module1500

- Implement Scene1501 (with yet unimpelemented stuff commented out)
- Add preliminary main loop to test stuff/updates
- Add dummy SoundResource
- And fix a mean bug/typo in some initializer lists...
(The intro now "runs" but doesn't show anything yet since the actual display code and other classes are not yet implemented yet.)
This commit is contained in:
johndoe123 2011-07-01 13:20:46 +00:00 committed by Willem Jan Palenstijn
parent f01f9343c8
commit 3c82668fe4
8 changed files with 186 additions and 54 deletions

View File

@ -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

View File

@ -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);

View File

@ -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 &param, Entity *sender) {
uint32 messageResult = Scene::handleMessage(messageNum, param, sender);
if (messageNum == 0x0009) {
_flag = true;
}
return messageResult;
}
} // End of namespace Neverhood

View File

@ -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 &param, Entity *sender);
};
} // End of namespace Neverhood
#endif /* NEVERHOOD_MODULE1500_H */

View File

@ -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
_gameModule = new GameModule(this);
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;
}
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;
}
}
}
} // End of namespace Neverhood

View File

@ -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:

View File

@ -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

View File

@ -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;