2009-06-12 12:40:18 +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.
|
2009-06-12 14:19:33 +00:00
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
2009-06-12 12:40:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/config-manager.h"
|
|
|
|
#include "common/events.h"
|
|
|
|
#include "common/system.h"
|
|
|
|
#include "common/file.h"
|
|
|
|
|
2009-06-12 17:34:06 +00:00
|
|
|
#include "asylum/asylum.h"
|
2009-06-13 19:05:11 +00:00
|
|
|
#include "asylum/resourcepack.h"
|
2009-06-12 12:40:18 +00:00
|
|
|
|
|
|
|
namespace Asylum {
|
|
|
|
|
|
|
|
AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
|
|
|
|
: Engine(system) {
|
|
|
|
|
|
|
|
Common::File::addDefaultDirectory(_gameDataDir.getChild("Data"));
|
|
|
|
Common::File::addDefaultDirectory(_gameDataDir.getChild("Vids"));
|
|
|
|
Common::File::addDefaultDirectory(_gameDataDir.getChild("Music"));
|
|
|
|
|
|
|
|
_eventMan->registerRandomSource(_rnd, "asylum");
|
|
|
|
}
|
|
|
|
|
|
|
|
AsylumEngine::~AsylumEngine() {
|
|
|
|
//Common::clearAllDebugChannels();
|
2009-06-14 14:31:23 +00:00
|
|
|
delete _mainMenu;
|
2009-06-12 22:42:45 +00:00
|
|
|
delete _scene;
|
2009-06-13 23:16:07 +00:00
|
|
|
delete _video;
|
2009-06-13 23:03:37 +00:00
|
|
|
delete _sound;
|
|
|
|
delete _screen;
|
2009-06-12 12:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Common::Error AsylumEngine::run() {
|
|
|
|
Common::Error err;
|
|
|
|
err = init();
|
|
|
|
if (err != Common::kNoError)
|
|
|
|
return err;
|
|
|
|
return go();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Will do the same as subroutine at address 0041A500
|
|
|
|
Common::Error AsylumEngine::init() {
|
|
|
|
// initialize engine objects
|
|
|
|
|
2009-06-12 20:07:11 +00:00
|
|
|
initGraphics(640, 480, true);
|
2009-06-12 20:38:38 +00:00
|
|
|
|
2009-06-13 23:03:37 +00:00
|
|
|
_screen = new Screen(_system);
|
|
|
|
_sound = new Sound(_mixer);
|
2009-06-13 23:16:07 +00:00
|
|
|
_video = new Video(_mixer);
|
2009-06-12 22:42:45 +00:00
|
|
|
_scene = new Scene(this);
|
2009-06-12 12:40:18 +00:00
|
|
|
|
|
|
|
// initializing game
|
|
|
|
// TODO: save dialogue key codes into sntrm_k.txt (need to figure out why they use such thing)
|
|
|
|
// TODO: get hand icon resource before starting main menu
|
|
|
|
// TODO: load startup configurations (address 0041A970)
|
|
|
|
// TODO: setup cinematics (address 0041A880) (probably we won't need it)
|
|
|
|
// TODO: init unknown game stuffs (address 0040F430)
|
|
|
|
|
|
|
|
// TODO: if savegame exists on folder, than start NewGame()
|
|
|
|
|
|
|
|
return Common::kNoError;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::Error AsylumEngine::go() {
|
2009-06-12 21:53:48 +00:00
|
|
|
// Play intro movie
|
|
|
|
// Disabled for quick testing
|
2009-06-13 23:16:07 +00:00
|
|
|
//_video->playVideo(0);
|
|
|
|
|
|
|
|
// DEBUG
|
|
|
|
// Testing new game state abstraction class
|
2009-06-14 14:31:23 +00:00
|
|
|
_mainMenu = new MainMenu(this);
|
2009-06-12 12:40:18 +00:00
|
|
|
|
2009-06-12 22:42:45 +00:00
|
|
|
// TODO: just some scene proof-of-concept
|
|
|
|
_scene->load(5);
|
|
|
|
|
2009-06-13 19:05:11 +00:00
|
|
|
|
2009-06-12 12:40:18 +00:00
|
|
|
// DEBUG
|
|
|
|
// Control loop test. Basically just keep the
|
|
|
|
// ScummVM window alive until ESC is pressed.
|
|
|
|
// This will facilitate drawing tests ;)
|
|
|
|
|
|
|
|
while (!shouldQuit()) {
|
2009-06-13 14:44:43 +00:00
|
|
|
|
2009-06-13 19:38:25 +00:00
|
|
|
checkForEvent(true);
|
2009-06-12 20:19:19 +00:00
|
|
|
|
2009-06-13 14:14:22 +00:00
|
|
|
waitForTimer(60);
|
2009-06-13 13:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return Common::kNoError;
|
|
|
|
}
|
2009-06-12 21:09:17 +00:00
|
|
|
|
2009-06-13 13:40:48 +00:00
|
|
|
void AsylumEngine::waitForTimer(int msec_delay) {
|
|
|
|
uint32 start_time = _system->getMillis();
|
|
|
|
|
|
|
|
while (_system->getMillis() < start_time + msec_delay) {
|
2009-06-13 19:38:25 +00:00
|
|
|
checkForEvent(false);
|
2009-06-13 13:40:48 +00:00
|
|
|
_system->updateScreen();
|
2009-06-12 12:40:18 +00:00
|
|
|
_system->delayMillis(10);
|
|
|
|
}
|
2009-06-13 13:40:48 +00:00
|
|
|
}
|
2009-06-12 12:40:18 +00:00
|
|
|
|
2009-06-13 19:38:25 +00:00
|
|
|
void AsylumEngine::checkForEvent(bool doUpdate) {
|
2009-06-13 13:40:48 +00:00
|
|
|
Common::Event ev;
|
|
|
|
|
|
|
|
if (_system->getEventManager()->pollEvent(ev)) {
|
|
|
|
if (ev.type == Common::EVENT_KEYDOWN) {
|
|
|
|
if (ev.kbd.keycode == Common::KEYCODE_ESCAPE) {
|
|
|
|
// Push a quit event
|
|
|
|
Common::Event event;
|
|
|
|
event.type = Common::EVENT_QUIT;
|
|
|
|
g_system->getEventManager()->pushEvent(event);
|
|
|
|
}
|
2009-06-13 13:29:56 +00:00
|
|
|
}
|
|
|
|
}
|
2009-06-13 19:38:25 +00:00
|
|
|
|
|
|
|
if (doUpdate) {
|
|
|
|
// Copy background image
|
2009-06-13 23:03:37 +00:00
|
|
|
_screen->copyBackBufferToScreen();
|
2009-06-13 19:38:25 +00:00
|
|
|
}
|
2009-06-14 14:31:23 +00:00
|
|
|
_mainMenu->handleEvent(&ev, doUpdate);
|
2009-06-13 13:29:56 +00:00
|
|
|
}
|
|
|
|
|
2009-06-12 12:40:18 +00:00
|
|
|
} // namespace Asylum
|