2009-06-01 18:05:46 +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/config-manager.h"
|
|
|
|
#include "common/events.h"
|
|
|
|
#include "common/system.h"
|
|
|
|
#include "common/file.h"
|
|
|
|
|
|
|
|
#include "asylum/asylum.h"
|
2009-06-05 02:51:23 +00:00
|
|
|
#include "asylum/screen.h"
|
2009-06-08 14:05:49 +00:00
|
|
|
|
2009-06-01 18:05:46 +00:00
|
|
|
namespace Asylum {
|
|
|
|
|
2009-06-05 02:51:23 +00:00
|
|
|
AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
|
2009-06-06 20:31:13 +00:00
|
|
|
: Engine(system) {
|
2009-06-01 18:05:46 +00:00
|
|
|
|
2009-06-06 20:31:13 +00:00
|
|
|
Common::File::addDefaultDirectory(_gameDataDir.getChild("Data"));
|
|
|
|
Common::File::addDefaultDirectory(_gameDataDir.getChild("Vids"));
|
2009-06-01 18:05:46 +00:00
|
|
|
|
2009-06-06 20:31:13 +00:00
|
|
|
_eventMan->registerRandomSource(_rnd, "asylum");
|
2009-06-01 18:05:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AsylumEngine::~AsylumEngine() {
|
2009-06-06 20:31:13 +00:00
|
|
|
//Common::clearAllDebugChannels();
|
|
|
|
delete _screen;
|
2009-06-08 14:05:49 +00:00
|
|
|
delete _resMgr;
|
2009-06-01 18:05:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Common::Error AsylumEngine::run() {
|
2009-06-06 20:31:13 +00:00
|
|
|
Common::Error err;
|
|
|
|
err = init();
|
|
|
|
if (err != Common::kNoError)
|
|
|
|
return err;
|
|
|
|
return go();
|
2009-06-05 02:51:23 +00:00
|
|
|
}
|
|
|
|
|
2009-06-06 20:31:13 +00:00
|
|
|
// Will do the same as subroutine at address 0041A500
|
2009-06-05 02:51:23 +00:00
|
|
|
Common::Error AsylumEngine::init() {
|
2009-06-06 20:31:13 +00:00
|
|
|
// initialize engine objects
|
2009-06-08 14:05:49 +00:00
|
|
|
|
|
|
|
_screen = new Screen(_system);
|
|
|
|
_resMgr = new ResourceManager;
|
2009-06-06 20:31:13 +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)
|
2009-06-08 14:05:49 +00:00
|
|
|
|
2009-06-06 20:31:13 +00:00
|
|
|
// TODO: load smaker intro movie (0)->(mov000.smk)
|
|
|
|
// TODO: if savegame exists on folder, than start NewGame()
|
|
|
|
|
|
|
|
return Common::kNoError;
|
2009-06-05 02:51:23 +00:00
|
|
|
}
|
2009-06-03 20:50:31 +00:00
|
|
|
|
2009-06-05 02:51:23 +00:00
|
|
|
Common::Error AsylumEngine::go() {
|
2009-06-06 20:31:13 +00:00
|
|
|
|
2009-06-08 14:05:49 +00:00
|
|
|
showMainMenu();
|
2009-06-06 20:31:13 +00:00
|
|
|
|
2009-06-08 14:05:49 +00:00
|
|
|
// DEBUG
|
2009-06-06 20:31:13 +00:00
|
|
|
// Control loop test. Basically just keep the
|
|
|
|
// ScummVM window alive until ESC is pressed.
|
|
|
|
// This will facilitate drawing tests ;)
|
|
|
|
bool end = false;
|
2009-06-11 00:19:06 +00:00
|
|
|
int updateCounter = 0;
|
2009-06-06 20:31:13 +00:00
|
|
|
Common::EventManager *em = _system->getEventManager();
|
|
|
|
while (!end) {
|
|
|
|
Common::Event ev;
|
|
|
|
if (em->pollEvent(ev)) {
|
|
|
|
if (ev.type == Common::EVENT_KEYDOWN) {
|
|
|
|
if (ev.kbd.keycode == Common::KEYCODE_ESCAPE)
|
|
|
|
end = true;
|
|
|
|
//if (ev.kbd.keycode == Common::KEYCODE_RETURN)
|
2009-06-05 11:53:56 +00:00
|
|
|
}
|
2009-06-11 00:19:06 +00:00
|
|
|
if (ev.type == Common::EVENT_MOUSEMOVE) {
|
|
|
|
updateCounter++;
|
|
|
|
if(updateCounter>6){
|
|
|
|
_screen->updateScreen();
|
|
|
|
updateCounter = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2009-06-05 11:53:56 +00:00
|
|
|
}
|
2009-06-06 20:31:13 +00:00
|
|
|
_system->delayMillis(10);
|
|
|
|
}
|
2009-06-05 11:53:56 +00:00
|
|
|
|
2009-06-06 20:31:13 +00:00
|
|
|
return Common::kNoError;
|
2009-06-01 18:05:46 +00:00
|
|
|
}
|
|
|
|
|
2009-06-08 14:05:49 +00:00
|
|
|
void AsylumEngine::showMainMenu() {
|
|
|
|
// eyes animation index table
|
|
|
|
//const uint32 eyesTable[8] = {3, 5, 1, 7, 4, 8, 2, 6};
|
2009-06-11 00:19:06 +00:00
|
|
|
PaletteBundle *pal = _resMgr->getPalette(1, 17);
|
|
|
|
GraphicResource *bg = _resMgr->getGraphic(1, 0)->getEntry(0);
|
|
|
|
GraphicResource *cur = _resMgr->getGraphic(1, 2)->getEntry(0);
|
|
|
|
|
|
|
|
_system->setMouseCursor(cur->data, cur->width, cur->height, 1, 1, 0);
|
2009-06-11 00:42:12 +00:00
|
|
|
_system->setCursorPalette(pal->getPalette(), 0, 1024);
|
2009-06-11 00:19:06 +00:00
|
|
|
_system->showMouse(true);
|
|
|
|
|
2009-06-08 14:05:49 +00:00
|
|
|
_screen->setFrontBuffer(
|
|
|
|
0, 0,
|
2009-06-11 00:19:06 +00:00
|
|
|
bg->width, bg->height,
|
|
|
|
bg->data);
|
2009-06-11 00:42:12 +00:00
|
|
|
_screen->setPalette(pal->getPalette());
|
2009-06-08 14:05:49 +00:00
|
|
|
_screen->updateScreen();
|
|
|
|
}
|
|
|
|
|
2009-06-01 18:05:46 +00:00
|
|
|
} // namespace Asylum
|