2011-06-22 22:58:51 +00:00
|
|
|
/* 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 "common/file.h"
|
|
|
|
#include "common/config-manager.h"
|
|
|
|
#include "base/plugins.h"
|
|
|
|
#include "base/version.h"
|
|
|
|
#include "graphics/cursorman.h"
|
|
|
|
#include "engines/util.h"
|
|
|
|
#include "neverhood/neverhood.h"
|
2011-06-24 13:12:42 +00:00
|
|
|
#include "neverhood/blbarchive.h"
|
2011-07-01 13:20:46 +00:00
|
|
|
#include "neverhood/gamemodule.h"
|
2011-06-24 23:25:01 +00:00
|
|
|
#include "neverhood/graphics.h"
|
2011-06-24 15:36:35 +00:00
|
|
|
#include "neverhood/resourceman.h"
|
2011-06-27 11:06:40 +00:00
|
|
|
#include "neverhood/resource.h"
|
2011-07-03 12:09:48 +00:00
|
|
|
#include "neverhood/screen.h"
|
2011-07-05 14:22:18 +00:00
|
|
|
#include "neverhood/staticdata.h"
|
2011-06-22 22:58:51 +00:00
|
|
|
|
|
|
|
namespace Neverhood {
|
|
|
|
|
|
|
|
NeverhoodEngine::NeverhoodEngine(OSystem *syst, const NeverhoodGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
|
|
|
|
// Setup mixer
|
|
|
|
if (!_mixer->isReady()) {
|
|
|
|
warning("Sound initialization failed.");
|
|
|
|
}
|
|
|
|
|
|
|
|
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
|
|
|
|
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
|
|
|
|
|
|
|
|
_rnd = new Common::RandomSource("neverhood");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
NeverhoodEngine::~NeverhoodEngine() {
|
|
|
|
delete _rnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::Error NeverhoodEngine::run() {
|
|
|
|
// Initialize backend
|
|
|
|
_system->beginGFXTransaction();
|
|
|
|
initCommonGFX(false);
|
|
|
|
_system->initSize(640, 480);
|
|
|
|
_system->endGFXTransaction();
|
|
|
|
|
|
|
|
_isSaveAllowed = false;
|
|
|
|
|
2011-07-05 14:22:18 +00:00
|
|
|
_staticData = new StaticData();
|
|
|
|
_staticData->load("neverhood.dat");
|
|
|
|
|
2011-07-03 12:09:48 +00:00
|
|
|
_screen = new Screen(this);
|
|
|
|
|
2011-06-24 23:25:01 +00:00
|
|
|
_res = new ResourceMan();
|
|
|
|
_res->addArchive("a.blb");
|
|
|
|
_res->addArchive("c.blb");
|
|
|
|
_res->addArchive("hd.blb");
|
|
|
|
_res->addArchive("i.blb");
|
|
|
|
_res->addArchive("m.blb");
|
|
|
|
_res->addArchive("s.blb");
|
|
|
|
_res->addArchive("t.blb");
|
|
|
|
|
2011-06-24 15:36:35 +00:00
|
|
|
#if 0
|
2011-06-24 13:12:42 +00:00
|
|
|
BlbArchive *blb = new BlbArchive();
|
|
|
|
blb->open("m.blb");
|
|
|
|
delete blb;
|
2011-06-24 15:36:35 +00:00
|
|
|
#endif
|
|
|
|
|
2011-06-24 23:25:01 +00:00
|
|
|
#if 0
|
|
|
|
ResourceFileEntry *r = _res->findEntry(0x50A80517);
|
2011-06-24 15:36:35 +00:00
|
|
|
#endif
|
2011-06-24 13:12:42 +00:00
|
|
|
|
2011-06-24 23:25:01 +00:00
|
|
|
#if 0
|
|
|
|
int resourceHandle = _res->useResource(0x0CA04202);
|
|
|
|
debug("resourceHandle = %d", resourceHandle);
|
|
|
|
byte *data = _res->loadResource(resourceHandle);
|
|
|
|
bool rle;
|
|
|
|
NDimensions dimensions;
|
|
|
|
NUnknown unknown;
|
|
|
|
byte *palette, *pixels;
|
|
|
|
parseBitmapResource(data, &rle, &dimensions, &unknown, &palette, &pixels);
|
|
|
|
debug("%d, %d", dimensions.width, dimensions.height);
|
|
|
|
byte *rawpixels = new byte[dimensions.width * dimensions.height];
|
|
|
|
memset(rawpixels, 0, dimensions.width * dimensions.height);
|
|
|
|
debug("rle = %d", rle);
|
|
|
|
unpackSpriteRle(pixels, dimensions.width, dimensions.height, rawpixels, dimensions.width, false, false);
|
|
|
|
Common::DumpFile d;
|
|
|
|
d.open("dump.0");
|
|
|
|
d.write(rawpixels, dimensions.width * dimensions.height);
|
|
|
|
d.close();
|
|
|
|
delete[] rawpixels;
|
|
|
|
_res->unloadResource(resourceHandle);
|
|
|
|
_res->unuseResource(resourceHandle);
|
|
|
|
#endif
|
|
|
|
|
2011-07-01 10:25:55 +00:00
|
|
|
#if 0
|
2011-06-27 11:06:40 +00:00
|
|
|
{ // Create a new scope
|
|
|
|
SpriteResource r(this);
|
|
|
|
BaseSurface *surf = new BaseSurface(this, 0, 640, 480);
|
|
|
|
r.load(0x0CA04202);
|
2011-06-30 09:55:59 +00:00
|
|
|
debug("r: width = %d; height = %d", r.getDimensions().width, r.getDimensions().height);
|
2011-06-27 11:06:40 +00:00
|
|
|
surf->drawSpriteResource(r);
|
|
|
|
delete surf;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-07-01 13:20:46 +00:00
|
|
|
#if 0
|
2011-07-01 10:25:55 +00:00
|
|
|
{ // Create a new scope
|
|
|
|
AnimResource r(this);
|
|
|
|
r.load(0x000540B0);
|
|
|
|
}
|
|
|
|
#endif
|
2011-06-24 23:25:01 +00:00
|
|
|
|
2011-07-01 13:20:46 +00:00
|
|
|
_gameModule = new GameModule(this);
|
2011-06-22 22:58:51 +00:00
|
|
|
|
2011-07-03 19:26:27 +00:00
|
|
|
// Preliminary main loop, needs some more work but works for testing
|
2011-07-01 13:20:46 +00:00
|
|
|
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;
|
|
|
|
}
|
2011-06-22 22:58:51 +00:00
|
|
|
}
|
2011-07-04 10:52:07 +00:00
|
|
|
|
2011-07-04 17:58:38 +00:00
|
|
|
//debug("millis %d", _system->getMillis());
|
2011-07-01 13:20:46 +00:00
|
|
|
_gameModule->handleUpdate();
|
2011-07-03 19:26:27 +00:00
|
|
|
_gameModule->draw();
|
2011-07-04 10:52:07 +00:00
|
|
|
_screen->wait();
|
|
|
|
_screen->update();
|
|
|
|
|
2011-07-04 17:58:38 +00:00
|
|
|
//debug("---------------------------------------");
|
2011-07-01 13:20:46 +00:00
|
|
|
|
2011-06-22 22:58:51 +00:00
|
|
|
}
|
2011-07-01 13:20:46 +00:00
|
|
|
|
|
|
|
delete _gameModule;
|
|
|
|
delete _res;
|
2011-07-03 12:09:48 +00:00
|
|
|
delete _screen;
|
2011-07-05 14:22:18 +00:00
|
|
|
|
|
|
|
delete _staticData;
|
2011-07-01 13:20:46 +00:00
|
|
|
|
|
|
|
debug("Ok.");
|
|
|
|
|
|
|
|
return Common::kNoError;
|
2011-06-22 22:58:51 +00:00
|
|
|
}
|
|
|
|
|
2011-07-05 13:28:43 +00:00
|
|
|
uint32 NeverhoodEngine::getGlobalVar(uint32 nameHash) {
|
|
|
|
// TODO
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NeverhoodEngine::setGlobalVar(uint32 nameHash, uint32 value) {
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 NeverhoodEngine::getSubVar(uint32 nameHash, uint32 subNameHash) {
|
|
|
|
// TODO
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NeverhoodEngine::setSubVar(uint32 nameHash, uint32 subNameHash, uint32 value) {
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2011-06-22 22:58:51 +00:00
|
|
|
} // End of namespace Neverhood
|