2003-03-05 19:04:34 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2006-01-18 17:39:49 +00:00
|
|
|
* Copyright (C) 2003-2006 The ScummVM project
|
2003-03-05 19:04:34 +00:00
|
|
|
*
|
|
|
|
* 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
|
2003-03-06 02:37:37 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2003-03-05 19:04:34 +00:00
|
|
|
* 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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2003-03-05 19:04:34 +00:00
|
|
|
*
|
2006-02-11 10:03:24 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2003-03-05 19:04:34 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2005-06-24 15:23:51 +00:00
|
|
|
#include "common/stdafx.h"
|
2003-09-18 18:23:53 +00:00
|
|
|
|
|
|
|
#include "base/plugins.h"
|
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
#include "common/config-manager.h"
|
2003-09-18 18:23:53 +00:00
|
|
|
#include "common/file.h"
|
2006-06-24 08:07:48 +00:00
|
|
|
#include "common/fs.h"
|
2007-03-17 00:53:21 +00:00
|
|
|
#include "common/events.h"
|
2005-01-10 22:06:49 +00:00
|
|
|
#include "common/system.h"
|
2003-10-05 20:21:20 +00:00
|
|
|
#include "common/timer.h"
|
2003-09-18 18:23:53 +00:00
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
#include "sky/control.h"
|
2003-04-25 15:17:53 +00:00
|
|
|
#include "sky/debug.h"
|
2003-10-05 20:21:20 +00:00
|
|
|
#include "sky/disk.h"
|
2004-09-13 17:05:23 +00:00
|
|
|
#include "sky/grid.h"
|
2003-10-05 20:21:20 +00:00
|
|
|
#include "sky/intro.h"
|
|
|
|
#include "sky/logic.h"
|
2003-05-05 13:19:59 +00:00
|
|
|
#include "sky/mouse.h"
|
2003-10-05 20:21:20 +00:00
|
|
|
#include "sky/music/adlibmusic.h"
|
|
|
|
#include "sky/music/gmmusic.h"
|
|
|
|
#include "sky/music/mt32music.h"
|
|
|
|
#include "sky/music/musicbase.h"
|
|
|
|
#include "sky/screen.h"
|
|
|
|
#include "sky/sky.h"
|
|
|
|
#include "sky/skydefs.h"
|
|
|
|
#include "sky/sound.h"
|
|
|
|
#include "sky/text.h"
|
2004-12-15 06:48:08 +00:00
|
|
|
#include "sky/compact.h"
|
2003-09-18 18:23:53 +00:00
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
#include "sound/mididrv.h"
|
|
|
|
#include "sound/mixer.h"
|
2003-03-05 19:04:34 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32_WCE
|
|
|
|
|
|
|
|
extern bool toolbar_drawn;
|
|
|
|
extern bool draw_keyboard;
|
|
|
|
#endif
|
|
|
|
|
2003-07-04 15:03:54 +00:00
|
|
|
/*
|
2003-07-04 15:14:47 +00:00
|
|
|
At the beginning the reverse engineers were happy, and did rejoice at
|
|
|
|
their task, for the engine before them did shineth and was full of
|
|
|
|
promise. But then they did look closer and see'th the aweful truth;
|
|
|
|
it's code was assembly and messy (rareth was its comments). And so large
|
|
|
|
were it's includes that did at first seem small; queereth also was its
|
2005-07-30 21:11:48 +00:00
|
|
|
compact(s). Then they did findeth another version, and this was slightly
|
2003-07-04 15:14:47 +00:00
|
|
|
different from the first. Then a third, and this was different again.
|
|
|
|
All different, but not really better, for all were not really compatible.
|
|
|
|
But, eventually, it did come to pass that Steel Sky was implemented on
|
|
|
|
a modern platform. And the programmers looked and saw that it was indeed a
|
|
|
|
miracle. But they were not joyous and instead did weep for nobody knew
|
|
|
|
just what had been done. Except people who read the source. Hello.
|
2003-07-04 15:03:54 +00:00
|
|
|
|
|
|
|
With apologies to the CD32 SteelSky file.
|
|
|
|
*/
|
|
|
|
|
2006-03-09 02:52:51 +00:00
|
|
|
static const PlainGameDescriptor skySetting =
|
2006-02-18 00:12:36 +00:00
|
|
|
{"sky", "Beneath a Steel Sky" };
|
2003-03-05 19:04:34 +00:00
|
|
|
|
2006-02-18 11:15:37 +00:00
|
|
|
GameList Engine_SKY_gameIDList() {
|
2003-10-17 23:16:53 +00:00
|
|
|
GameList games;
|
2003-11-01 16:39:26 +00:00
|
|
|
games.push_back(skySetting);
|
2003-10-17 23:16:53 +00:00
|
|
|
return games;
|
|
|
|
}
|
|
|
|
|
2006-03-09 02:52:51 +00:00
|
|
|
GameDescriptor Engine_SKY_findGameID(const char *gameid) {
|
2006-03-02 22:29:01 +00:00
|
|
|
if (0 == scumm_stricmp(gameid, skySetting.gameid))
|
2006-02-18 11:15:37 +00:00
|
|
|
return skySetting;
|
2006-03-09 02:52:51 +00:00
|
|
|
return GameDescriptor();
|
2006-02-18 11:15:37 +00:00
|
|
|
}
|
|
|
|
|
2006-10-02 22:26:57 +00:00
|
|
|
struct SkyVersion {
|
|
|
|
int dinnerTableEntries;
|
|
|
|
int dataDiskSize;
|
|
|
|
const char *extraDesc;
|
|
|
|
int version;
|
|
|
|
};
|
|
|
|
|
|
|
|
// TODO: Would be nice if Disk::determineGameVersion() used this table, too.
|
|
|
|
static const SkyVersion skyVersions[] = {
|
|
|
|
{ 243, -1, "pc gamer demo", 109 },
|
|
|
|
{ 247, -1, "floppy demo", 267 },
|
|
|
|
{ 1404, -1, "floppy", 288 },
|
|
|
|
{ 1413, -1, "floppy", 303 },
|
|
|
|
{ 1445, 8830435, "floppy", 348 },
|
|
|
|
{ 1445, -1, "floppy", 331 },
|
|
|
|
{ 1711, -1, "cd demo", 365 },
|
|
|
|
{ 5099, -1, "cd", 368 },
|
|
|
|
{ 5097, -1, "cd", 372 },
|
|
|
|
{ 0, 0, 0, 0 }
|
|
|
|
};
|
|
|
|
|
2007-01-20 21:27:57 +00:00
|
|
|
GameList Engine_SKY_detectGames(const FSList &fslist) {
|
|
|
|
GameList detectedGames;
|
2006-10-02 22:26:57 +00:00
|
|
|
bool hasSkyDsk = false;
|
|
|
|
bool hasSkyDnr = false;
|
|
|
|
int dinnerTableEntries = -1;
|
|
|
|
int dataDiskSize = -1;
|
|
|
|
|
2003-10-17 23:16:53 +00:00
|
|
|
// Iterate over all files in the given directory
|
2004-02-05 00:19:57 +00:00
|
|
|
for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
|
2004-12-09 15:06:49 +00:00
|
|
|
if (!file->isDirectory()) {
|
2006-07-22 14:50:50 +00:00
|
|
|
const char *fileName = file->name().c_str();
|
2004-12-09 15:06:49 +00:00
|
|
|
|
|
|
|
if (0 == scumm_stricmp("sky.dsk", fileName)) {
|
2006-10-02 22:26:57 +00:00
|
|
|
Common::File dataDisk;
|
|
|
|
if (dataDisk.open(file->path())) {
|
|
|
|
hasSkyDsk = true;
|
|
|
|
dataDiskSize = dataDisk.size();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0 == scumm_stricmp("sky.dnr", fileName)) {
|
|
|
|
Common::File dinner;
|
|
|
|
if (dinner.open(file->path())) {
|
|
|
|
hasSkyDnr = true;
|
|
|
|
dinnerTableEntries = dinner.readUint32LE();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hasSkyDsk && hasSkyDnr) {
|
|
|
|
// Match found, add to list of candidates, then abort inner loop.
|
|
|
|
// The game detector uses US English by default. We want British
|
|
|
|
// English to match the recorded voices better.
|
2007-01-20 21:27:57 +00:00
|
|
|
GameDescriptor dg(skySetting.gameid, skySetting.description, Common::UNK_LANG, Common::kPlatformUnknown);
|
2006-10-02 22:26:57 +00:00
|
|
|
const SkyVersion *sv = skyVersions;
|
|
|
|
while (sv->dinnerTableEntries) {
|
|
|
|
if (dinnerTableEntries == sv->dinnerTableEntries &&
|
|
|
|
(sv->dataDiskSize == dataDiskSize || sv->dataDiskSize == -1)) {
|
|
|
|
char buf[32];
|
|
|
|
snprintf(buf, sizeof(buf), "v0.0%d %s", sv->version, sv->extraDesc);
|
|
|
|
dg.updateDesc(buf);
|
2004-12-09 15:06:49 +00:00
|
|
|
break;
|
|
|
|
}
|
2006-10-02 22:26:57 +00:00
|
|
|
++sv;
|
2003-10-17 23:16:53 +00:00
|
|
|
}
|
2006-10-02 22:26:57 +00:00
|
|
|
detectedGames.push_back(dg);
|
2003-10-17 23:16:53 +00:00
|
|
|
}
|
2006-10-02 22:26:57 +00:00
|
|
|
|
2003-10-17 23:16:53 +00:00
|
|
|
return detectedGames;
|
2003-03-05 19:04:34 +00:00
|
|
|
}
|
|
|
|
|
2006-04-29 00:27:20 +00:00
|
|
|
PluginError Engine_SKY_create(OSystem *syst, Engine **engine) {
|
|
|
|
assert(engine);
|
|
|
|
*engine = new Sky::SkyEngine(syst);
|
|
|
|
return kNoError;
|
2003-03-05 19:04:34 +00:00
|
|
|
}
|
|
|
|
|
2006-07-31 13:41:21 +00:00
|
|
|
REGISTER_PLUGIN(SKY, "Beneath a Steel Sky", "Beneath a Steel Sky (C) Revolution");
|
2003-09-18 18:23:53 +00:00
|
|
|
|
2004-01-03 01:58:58 +00:00
|
|
|
|
|
|
|
namespace Sky {
|
|
|
|
|
2004-12-15 06:48:08 +00:00
|
|
|
void *SkyEngine::_itemList[300];
|
2003-04-25 15:17:53 +00:00
|
|
|
|
2005-04-01 07:33:39 +00:00
|
|
|
SystemVars SkyEngine::_systemVars = {0, 0, 0, 0, 4316, 0, 0, false, false, false };
|
2003-06-01 21:21:10 +00:00
|
|
|
|
2006-02-12 01:42:34 +00:00
|
|
|
SkyEngine::SkyEngine(OSystem *syst)
|
2005-09-22 22:55:01 +00:00
|
|
|
: Engine(syst), _fastMode(0), _debugger(0) {
|
2003-03-05 19:04:34 +00:00
|
|
|
}
|
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
SkyEngine::~SkyEngine() {
|
2003-05-27 16:42:20 +00:00
|
|
|
|
2005-12-05 05:02:43 +00:00
|
|
|
_timer->removeTimerProc(&timerHandler);
|
|
|
|
|
2003-05-27 16:42:20 +00:00
|
|
|
delete _skyLogic;
|
|
|
|
delete _skySound;
|
|
|
|
delete _skyMusic;
|
|
|
|
delete _skyText;
|
|
|
|
delete _skyMouse;
|
|
|
|
delete _skyScreen;
|
2004-09-13 17:05:23 +00:00
|
|
|
delete _debugger;
|
2005-12-05 05:02:43 +00:00
|
|
|
delete _skyDisk;
|
2005-12-13 14:31:13 +00:00
|
|
|
delete _skyControl;
|
|
|
|
delete _skyCompact;
|
2005-12-05 05:02:43 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < 300; i++)
|
|
|
|
if (_itemList[i])
|
|
|
|
free(_itemList[i]);
|
2003-03-05 19:04:34 +00:00
|
|
|
}
|
|
|
|
|
2006-09-16 19:31:23 +00:00
|
|
|
GUI::Debugger *SkyEngine::getDebugger() {
|
|
|
|
return _debugger;
|
2003-03-07 15:38:11 +00:00
|
|
|
}
|
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
void SkyEngine::initVirgin() {
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-07-17 00:17:42 +00:00
|
|
|
_skyScreen->setPalette(60111);
|
|
|
|
_skyScreen->showScreen(60110);
|
|
|
|
}
|
|
|
|
|
2004-12-16 04:22:32 +00:00
|
|
|
void SkyEngine::handleKey(void) {
|
2003-07-10 08:24:16 +00:00
|
|
|
|
2005-04-01 07:33:39 +00:00
|
|
|
if (_keyPressed && _systemVars.paused) {
|
|
|
|
_skySound->fnUnPauseFx();
|
|
|
|
_systemVars.paused = false;
|
|
|
|
_skyScreen->setPaletteEndian((uint8 *)_skyCompact->fetchCpt(SkyEngine::_systemVars.currentPalette));
|
|
|
|
_keyFlags = _keyPressed = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-12-16 04:22:32 +00:00
|
|
|
if (_keyFlags == OSystem::KBD_CTRL) {
|
|
|
|
if (_keyPressed == 'f')
|
|
|
|
_fastMode ^= 1;
|
|
|
|
else if (_keyPressed == 'g')
|
|
|
|
_fastMode ^= 2;
|
|
|
|
else if (_keyPressed == 'd')
|
|
|
|
_debugger->attach();
|
|
|
|
} else {
|
2005-04-01 07:33:39 +00:00
|
|
|
switch (_keyPressed) {
|
|
|
|
case '`':
|
|
|
|
case '~':
|
|
|
|
case '#':
|
2004-12-16 04:22:32 +00:00
|
|
|
_debugger->attach();
|
2005-04-01 07:33:39 +00:00
|
|
|
break;
|
|
|
|
case 63:
|
2004-12-16 04:22:32 +00:00
|
|
|
_skyControl->doControlPanel();
|
2005-04-01 07:33:39 +00:00
|
|
|
break;
|
2003-07-10 08:24:16 +00:00
|
|
|
|
2005-04-01 07:33:39 +00:00
|
|
|
case 27:
|
|
|
|
if (!_systemVars.pastIntro)
|
|
|
|
_skyControl->restartGame();
|
|
|
|
break;
|
2003-07-12 02:07:37 +00:00
|
|
|
|
2005-04-01 07:33:39 +00:00
|
|
|
case '.':
|
2004-12-16 04:22:32 +00:00
|
|
|
_skyMouse->logicClick();
|
2005-04-01 07:33:39 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'p':
|
|
|
|
_skyScreen->halvePalette();
|
|
|
|
_skySound->fnPauseFx();
|
|
|
|
_systemVars.paused = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
2004-09-13 17:05:23 +00:00
|
|
|
}
|
2004-12-16 04:22:32 +00:00
|
|
|
_keyFlags = _keyPressed = 0;
|
2003-07-12 02:07:37 +00:00
|
|
|
}
|
|
|
|
|
2004-11-23 00:03:25 +00:00
|
|
|
int SkyEngine::go() {
|
2003-04-25 15:17:53 +00:00
|
|
|
|
2005-12-05 05:02:43 +00:00
|
|
|
_systemVars.quitGame = false;
|
|
|
|
|
2004-12-16 04:22:32 +00:00
|
|
|
_keyFlags = _keyPressed = 0;
|
|
|
|
|
|
|
|
uint16 result = 0;
|
|
|
|
if (ConfMan.hasKey("save_slot") && ConfMan.getInt("save_slot") >= 0)
|
|
|
|
result = _skyControl->quickXRestore(ConfMan.getInt("save_slot"));
|
|
|
|
|
2005-07-30 21:11:48 +00:00
|
|
|
if (result != GAME_RESTORED) {
|
2004-12-16 04:22:32 +00:00
|
|
|
bool introSkipped = false;
|
2005-12-05 05:02:43 +00:00
|
|
|
if (_systemVars.gameVersion > 267) { // don't do intro for floppydemos
|
2004-01-03 15:57:57 +00:00
|
|
|
_skyIntro = new Intro(_skyDisk, _skyScreen, _skyMusic, _skySound, _skyText, _mixer, _system);
|
2003-07-17 00:17:42 +00:00
|
|
|
introSkipped = !_skyIntro->doIntro(_floppyIntro);
|
2005-12-05 05:02:43 +00:00
|
|
|
_systemVars.quitGame = _skyIntro->_quitProg;
|
|
|
|
|
2003-07-17 00:17:42 +00:00
|
|
|
delete _skyIntro;
|
|
|
|
}
|
2003-05-27 16:42:20 +00:00
|
|
|
|
2005-12-05 05:02:43 +00:00
|
|
|
if (!_systemVars.quitGame) {
|
|
|
|
_skyLogic->initScreen0();
|
|
|
|
if (introSkipped)
|
|
|
|
_skyControl->restartGame();
|
|
|
|
}
|
2004-12-16 04:22:32 +00:00
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-09-28 20:19:37 +00:00
|
|
|
_lastSaveTime = _system->getMillis();
|
2003-07-11 22:19:16 +00:00
|
|
|
|
2005-12-13 15:05:06 +00:00
|
|
|
uint32 delayCount = _system->getMillis();
|
2005-12-05 05:02:43 +00:00
|
|
|
while (!_systemVars.quitGame) {
|
2004-12-16 04:22:32 +00:00
|
|
|
if (_debugger->isAttached())
|
2004-09-13 17:05:23 +00:00
|
|
|
_debugger->onFrame();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-11-23 19:11:33 +00:00
|
|
|
if (shouldPerformAutoSave(_lastSaveTime)) {
|
2003-07-31 01:57:05 +00:00
|
|
|
if (_skyControl->loadSaveAllowed()) {
|
2004-09-28 20:19:37 +00:00
|
|
|
_lastSaveTime = _system->getMillis();
|
2003-07-14 09:16:12 +00:00
|
|
|
_skyControl->doAutoSave();
|
2003-07-31 01:57:05 +00:00
|
|
|
} else
|
|
|
|
_lastSaveTime += 30 * 1000; // try again in 30 secs
|
2003-07-11 22:19:16 +00:00
|
|
|
}
|
2003-07-04 20:14:11 +00:00
|
|
|
_skySound->checkFxQueue();
|
2007-03-14 12:32:42 +00:00
|
|
|
_skyMouse->mouseEngine();
|
2004-12-16 04:22:32 +00:00
|
|
|
handleKey();
|
2005-12-13 15:05:06 +00:00
|
|
|
if (_systemVars.paused) {
|
|
|
|
do {
|
|
|
|
_system->updateScreen();
|
|
|
|
delay(50);
|
|
|
|
handleKey();
|
|
|
|
} while (_systemVars.paused);
|
|
|
|
delayCount = _system->getMillis();
|
2005-04-01 07:33:39 +00:00
|
|
|
}
|
|
|
|
|
2003-04-25 15:17:53 +00:00
|
|
|
_skyLogic->engine();
|
2004-12-16 04:22:32 +00:00
|
|
|
_skyScreen->recreate();
|
|
|
|
_skyScreen->spriteEngine();
|
|
|
|
if (_debugger->showGrid()) {
|
|
|
|
_skyScreen->showGrid(_skyLogic->_skyGrid->giveGrid(Logic::_scriptVariables[SCREEN]));
|
|
|
|
_skyScreen->forceRefresh();
|
2003-07-01 13:04:00 +00:00
|
|
|
}
|
2004-12-16 04:22:32 +00:00
|
|
|
_skyScreen->flip();
|
|
|
|
|
|
|
|
if (_fastMode & 2)
|
|
|
|
delay(0);
|
|
|
|
else if (_fastMode & 1)
|
|
|
|
delay(10);
|
2005-12-13 15:05:06 +00:00
|
|
|
else {
|
|
|
|
delayCount += _systemVars.gameSpeed;
|
|
|
|
int needDelay = delayCount - (int)_system->getMillis();
|
|
|
|
if ((needDelay < 0) || (needDelay > 4 * _systemVars.gameSpeed)) {
|
|
|
|
needDelay = 0;
|
|
|
|
delayCount = _system->getMillis();
|
|
|
|
}
|
|
|
|
delay(needDelay);
|
|
|
|
}
|
2003-03-05 19:04:34 +00:00
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-12-05 05:02:43 +00:00
|
|
|
_skyControl->showGameQuitMsg();
|
|
|
|
_skyMusic->stopMusic();
|
|
|
|
ConfMan.flushToDisk();
|
|
|
|
delay(1500);
|
2004-11-23 00:03:25 +00:00
|
|
|
return 0;
|
2003-03-05 19:04:34 +00:00
|
|
|
}
|
|
|
|
|
2006-04-15 20:36:41 +00:00
|
|
|
int SkyEngine::init() {
|
2004-11-24 00:14:21 +00:00
|
|
|
_system->beginGFXTransaction();
|
2006-04-15 20:36:41 +00:00
|
|
|
initCommonGFX(false);
|
2004-11-24 00:14:21 +00:00
|
|
|
_system->initSize(320, 200);
|
|
|
|
_system->endGFXTransaction();
|
2004-11-15 20:44:56 +00:00
|
|
|
|
|
|
|
if (!_mixer->isReady())
|
|
|
|
warning("Sound initialisation failed");
|
|
|
|
|
2006-01-17 00:24:01 +00:00
|
|
|
if (ConfMan.getBool("sfx_mute")) {
|
|
|
|
SkyEngine::_systemVars.systemFlags |= SF_FX_OFF;
|
2007-02-10 18:10:55 +00:00
|
|
|
}
|
|
|
|
if (ConfMan.getBool("music_mute")) {
|
|
|
|
SkyEngine::_systemVars.systemFlags |= SF_MUS_OFF;
|
2006-01-17 00:24:01 +00:00
|
|
|
}
|
2005-05-10 23:48:48 +00:00
|
|
|
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
|
|
|
|
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));
|
2004-11-15 20:44:56 +00:00
|
|
|
_floppyIntro = ConfMan.getBool("alt_intro");
|
|
|
|
|
2006-05-01 22:27:56 +00:00
|
|
|
_skyDisk = new Disk();
|
2004-01-03 15:57:57 +00:00
|
|
|
_skySound = new Sound(_mixer, _skyDisk, ConfMan.getInt("sfx_volume"));
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-06-01 21:21:10 +00:00
|
|
|
_systemVars.gameVersion = _skyDisk->determineGameVersion();
|
2003-05-28 23:31:43 +00:00
|
|
|
|
2005-12-30 14:18:21 +00:00
|
|
|
int midiDriver = MidiDriver::detectMusicDriver(MDT_ADLIB | MDT_MIDI | MDT_PREFER_MIDI);
|
2003-10-18 00:22:46 +00:00
|
|
|
if (midiDriver == MD_ADLIB) {
|
2003-06-01 21:21:10 +00:00
|
|
|
_systemVars.systemFlags |= SF_SBLASTER;
|
2005-01-28 22:05:51 +00:00
|
|
|
_skyMusic = new AdlibMusic(_mixer, _skyDisk);
|
2003-05-03 02:59:45 +00:00
|
|
|
} else {
|
2003-06-01 21:21:10 +00:00
|
|
|
_systemVars.systemFlags |= SF_ROLAND;
|
2005-12-30 14:18:21 +00:00
|
|
|
if ((midiDriver == MD_MT32) || ConfMan.getBool("native_mt32"))
|
2005-01-28 22:05:51 +00:00
|
|
|
_skyMusic = new MT32Music(MidiDriver::createMidi(midiDriver), _skyDisk);
|
2003-06-22 21:42:59 +00:00
|
|
|
else
|
2005-01-28 22:05:51 +00:00
|
|
|
_skyMusic = new GmMusic(MidiDriver::createMidi(midiDriver), _skyDisk);
|
2003-05-03 02:59:45 +00:00
|
|
|
}
|
2003-07-05 09:08:53 +00:00
|
|
|
|
2003-07-10 10:36:24 +00:00
|
|
|
if (isCDVersion()) {
|
2003-12-02 08:12:39 +00:00
|
|
|
if (ConfMan.hasKey("nosubtitles")) {
|
|
|
|
warning("Configuration key 'nosubtitles' is deprecated. Use 'subtitles' instead");
|
2003-12-21 15:29:52 +00:00
|
|
|
if (!ConfMan.getBool("nosubtitles"))
|
2003-12-02 08:12:39 +00:00
|
|
|
_systemVars.systemFlags |= SF_ALLOW_TEXT;
|
|
|
|
}
|
|
|
|
|
2003-12-02 08:09:14 +00:00
|
|
|
if (ConfMan.getBool("subtitles"))
|
|
|
|
_systemVars.systemFlags |= SF_ALLOW_TEXT;
|
2006-01-17 00:24:01 +00:00
|
|
|
|
|
|
|
if (!ConfMan.getBool("speech_mute"))
|
|
|
|
_systemVars.systemFlags |= SF_ALLOW_SPEECH;
|
|
|
|
|
2003-07-10 10:36:24 +00:00
|
|
|
} else
|
2003-06-27 02:54:05 +00:00
|
|
|
_systemVars.systemFlags |= SF_ALLOW_TEXT;
|
|
|
|
|
2003-06-02 03:30:41 +00:00
|
|
|
_systemVars.systemFlags |= SF_PLAY_VOCS;
|
2003-06-27 02:54:05 +00:00
|
|
|
_systemVars.gameSpeed = 50;
|
2003-05-03 02:59:45 +00:00
|
|
|
|
2004-12-15 06:48:08 +00:00
|
|
|
_skyCompact = new SkyCompact();
|
|
|
|
_skyText = new Text(_skyDisk, _skyCompact);
|
|
|
|
_skyMouse = new Mouse(_system, _skyDisk, _skyCompact);
|
|
|
|
_skyScreen = new Screen(_system, _skyDisk, _skyCompact);
|
2003-05-27 16:42:20 +00:00
|
|
|
|
2003-03-07 14:52:24 +00:00
|
|
|
initVirgin();
|
2003-04-05 18:01:29 +00:00
|
|
|
initItemList();
|
2003-05-01 14:10:42 +00:00
|
|
|
loadFixedItems();
|
2004-12-15 06:48:08 +00:00
|
|
|
_skyLogic = new Logic(_skyCompact, _skyScreen, _skyDisk, _skyText, _skyMusic, _skyMouse, _skySound);
|
2003-06-05 18:54:26 +00:00
|
|
|
_skyMouse->useLogicInstance(_skyLogic);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-11-10 01:04:12 +00:00
|
|
|
// initialize timer *after* _skyScreen has been initialized.
|
2003-10-17 16:39:32 +00:00
|
|
|
_timer->installTimerProc(&timerHandler, 1000000 / 50, this); //call 50 times per second
|
2003-06-22 21:42:59 +00:00
|
|
|
|
2004-12-15 06:48:08 +00:00
|
|
|
_skyControl = new Control(_saveFileMan, _skyScreen, _skyDisk, _skyMouse, _skyText, _skyMusic, _skyLogic, _skySound, _skyCompact, _system);
|
2003-07-01 13:04:00 +00:00
|
|
|
_skyLogic->useControlInstance(_skyControl);
|
2003-07-03 17:17:32 +00:00
|
|
|
|
2003-10-17 15:35:46 +00:00
|
|
|
switch (Common::parseLanguage(ConfMan.get("language"))) {
|
2005-09-09 10:12:38 +00:00
|
|
|
case Common::EN_USA:
|
|
|
|
_systemVars.language = SKY_USA;
|
|
|
|
break;
|
2003-10-17 15:35:46 +00:00
|
|
|
case Common::DE_DEU:
|
|
|
|
_systemVars.language = SKY_GERMAN;
|
|
|
|
break;
|
|
|
|
case Common::FR_FRA:
|
|
|
|
_systemVars.language = SKY_FRENCH;
|
|
|
|
break;
|
|
|
|
case Common::IT_ITA:
|
|
|
|
_systemVars.language = SKY_ITALIAN;
|
|
|
|
break;
|
|
|
|
case Common::PT_BRA:
|
|
|
|
_systemVars.language = SKY_PORTUGUESE;
|
|
|
|
break;
|
|
|
|
case Common::ES_ESP:
|
|
|
|
_systemVars.language = SKY_SPANISH;
|
|
|
|
break;
|
|
|
|
case Common::SE_SWE:
|
|
|
|
_systemVars.language = SKY_SWEDISH;
|
|
|
|
break;
|
|
|
|
case Common::EN_GRB:
|
|
|
|
_systemVars.language = SKY_ENGLISH;
|
|
|
|
break;
|
|
|
|
default:
|
2005-09-09 10:12:38 +00:00
|
|
|
_systemVars.language = SKY_ENGLISH;
|
2003-10-17 15:35:46 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-07-12 05:38:04 +00:00
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
if (!_skyDisk->fileExists(60600 + SkyEngine::_systemVars.language * 8)) {
|
2003-07-12 15:26:07 +00:00
|
|
|
warning("The language you selected does not exist in your BASS version.");
|
|
|
|
if (_skyDisk->fileExists(60600))
|
2005-12-05 05:02:43 +00:00
|
|
|
SkyEngine::_systemVars.language = SKY_ENGLISH; // default to GB english if it exists..
|
2003-07-12 15:26:07 +00:00
|
|
|
else if (_skyDisk->fileExists(60600 + SKY_USA * 8))
|
2005-12-05 05:02:43 +00:00
|
|
|
SkyEngine::_systemVars.language = SKY_USA; // try US english...
|
2003-07-12 15:26:07 +00:00
|
|
|
else
|
|
|
|
for (uint8 cnt = SKY_ENGLISH; cnt <= SKY_SPANISH; cnt++)
|
2005-12-05 05:02:43 +00:00
|
|
|
if (_skyDisk->fileExists(60600 + cnt * 8)) { // pick the first language we can find
|
2003-10-05 20:21:20 +00:00
|
|
|
SkyEngine::_systemVars.language = cnt;
|
2003-07-12 15:26:07 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-07-12 05:38:04 +00:00
|
|
|
}
|
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
_skyMusic->setVolume(ConfMan.getInt("music_volume") >> 1);
|
2004-09-13 17:05:23 +00:00
|
|
|
|
2004-12-15 06:48:08 +00:00
|
|
|
_debugger = new Debugger(_skyLogic, _skyMouse, _skyScreen, _skyCompact);
|
2004-11-23 00:03:25 +00:00
|
|
|
return 0;
|
2003-04-05 18:01:29 +00:00
|
|
|
}
|
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
void SkyEngine::initItemList() {
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-04-05 18:01:29 +00:00
|
|
|
//See List.asm for (cryptic) item # descriptions
|
|
|
|
|
|
|
|
for (int i = 0; i < 300; i++)
|
2004-12-15 06:48:08 +00:00
|
|
|
_itemList[i] = NULL;
|
2003-04-25 15:17:53 +00:00
|
|
|
}
|
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
void SkyEngine::loadFixedItems(void) {
|
2003-05-01 14:10:42 +00:00
|
|
|
|
2004-12-15 06:48:08 +00:00
|
|
|
_itemList[49] = _skyDisk->loadFile(49);
|
|
|
|
_itemList[50] = _skyDisk->loadFile(50);
|
|
|
|
_itemList[73] = _skyDisk->loadFile(73);
|
|
|
|
_itemList[262] = _skyDisk->loadFile(262);
|
|
|
|
|
|
|
|
if (!isDemo()) {
|
|
|
|
_itemList[36] = _skyDisk->loadFile(36);
|
|
|
|
_itemList[263] = _skyDisk->loadFile(263);
|
|
|
|
_itemList[264] = _skyDisk->loadFile(264);
|
|
|
|
_itemList[265] = _skyDisk->loadFile(265);
|
|
|
|
_itemList[266] = _skyDisk->loadFile(266);
|
|
|
|
_itemList[267] = _skyDisk->loadFile(267);
|
|
|
|
_itemList[269] = _skyDisk->loadFile(269);
|
|
|
|
_itemList[271] = _skyDisk->loadFile(271);
|
|
|
|
_itemList[272] = _skyDisk->loadFile(272);
|
2005-07-30 21:11:48 +00:00
|
|
|
}
|
2003-05-01 14:10:42 +00:00
|
|
|
}
|
|
|
|
|
2004-12-15 06:48:08 +00:00
|
|
|
void *SkyEngine::fetchItem(uint32 num) {
|
2003-05-27 16:42:20 +00:00
|
|
|
|
|
|
|
return _itemList[num];
|
|
|
|
}
|
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
void SkyEngine::timerHandler(void *refCon) {
|
2003-05-14 22:33:39 +00:00
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
((SkyEngine *)refCon)->gotTimerTick();
|
2003-05-14 22:33:39 +00:00
|
|
|
}
|
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
void SkyEngine::gotTimerTick(void) {
|
2003-05-14 22:33:39 +00:00
|
|
|
|
|
|
|
_skyScreen->handleTimer();
|
|
|
|
}
|
|
|
|
|
2004-12-16 04:22:32 +00:00
|
|
|
void SkyEngine::delay(int32 amount) {
|
2003-03-07 14:52:24 +00:00
|
|
|
|
2007-03-17 16:22:51 +00:00
|
|
|
Common::EventManager *eventMan = _system->getEventManager();
|
2003-03-05 19:04:34 +00:00
|
|
|
OSystem::Event event;
|
|
|
|
|
2004-09-28 20:19:37 +00:00
|
|
|
uint32 start = _system->getMillis();
|
2004-12-16 04:22:32 +00:00
|
|
|
_keyFlags = _keyPressed = 0; //reset
|
|
|
|
|
|
|
|
if (amount < 0)
|
|
|
|
amount = 0;
|
2003-03-05 19:04:34 +00:00
|
|
|
|
|
|
|
do {
|
2007-03-17 00:53:21 +00:00
|
|
|
while (eventMan->pollEvent(event)) {
|
2004-12-05 17:42:20 +00:00
|
|
|
switch (event.type) {
|
2003-09-24 06:33:59 +00:00
|
|
|
case OSystem::EVENT_KEYDOWN:
|
2004-12-16 04:22:32 +00:00
|
|
|
_keyFlags = event.kbd.flags;
|
2006-01-22 00:11:58 +00:00
|
|
|
if (_keyFlags == OSystem::KBD_CTRL)
|
|
|
|
_keyPressed = event.kbd.keycode;
|
|
|
|
else
|
|
|
|
_keyPressed = (byte)event.kbd.ascii;
|
2003-09-24 06:33:59 +00:00
|
|
|
break;
|
|
|
|
case OSystem::EVENT_MOUSEMOVE:
|
|
|
|
if (!(_systemVars.systemFlags & SF_MOUSE_LOCKED)) {
|
2007-03-14 12:32:42 +00:00
|
|
|
_skyMouse->mouseMoved(event.mouse.x, event.mouse.y);
|
2003-09-24 06:33:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case OSystem::EVENT_LBUTTONDOWN:
|
2007-03-17 16:22:51 +00:00
|
|
|
if (!(_systemVars.systemFlags & SF_MOUSE_LOCKED)) {
|
|
|
|
_skyMouse->mouseMoved(event.mouse.x, event.mouse.y);
|
|
|
|
}
|
2003-09-24 06:33:59 +00:00
|
|
|
_skyMouse->buttonPressed(2);
|
|
|
|
break;
|
|
|
|
case OSystem::EVENT_RBUTTONDOWN:
|
2007-03-17 16:22:51 +00:00
|
|
|
if (!(_systemVars.systemFlags & SF_MOUSE_LOCKED)) {
|
|
|
|
_skyMouse->mouseMoved(event.mouse.x, event.mouse.y);
|
|
|
|
}
|
2003-09-24 06:33:59 +00:00
|
|
|
_skyMouse->buttonPressed(1);
|
|
|
|
break;
|
|
|
|
case OSystem::EVENT_QUIT:
|
2005-12-05 05:02:43 +00:00
|
|
|
_systemVars.quitGame = true;
|
2003-09-24 06:33:59 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2003-03-05 19:04:34 +00:00
|
|
|
}
|
|
|
|
}
|
2004-12-20 16:48:49 +00:00
|
|
|
|
2004-12-16 04:22:32 +00:00
|
|
|
if (amount > 0)
|
|
|
|
_system->delayMillis((amount > 10) ? 10 : amount);
|
2003-03-05 19:04:34 +00:00
|
|
|
|
2004-12-16 04:22:32 +00:00
|
|
|
} while (_system->getMillis() < start + amount);
|
2003-03-05 19:04:34 +00:00
|
|
|
}
|
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
bool SkyEngine::isDemo(void) {
|
2003-06-01 21:21:10 +00:00
|
|
|
switch (_systemVars.gameVersion) {
|
2003-07-12 10:02:12 +00:00
|
|
|
case 109: // pc gamer demo
|
2003-07-04 23:26:46 +00:00
|
|
|
case 267: // floppy demo
|
|
|
|
case 365: // cd demo
|
2003-04-07 20:44:52 +00:00
|
|
|
return true;
|
|
|
|
case 288:
|
2003-04-21 14:12:19 +00:00
|
|
|
case 303:
|
2003-04-07 20:44:52 +00:00
|
|
|
case 331:
|
2003-07-04 23:26:46 +00:00
|
|
|
case 348:
|
2003-04-07 20:44:52 +00:00
|
|
|
case 368:
|
2003-04-08 12:19:15 +00:00
|
|
|
case 372:
|
|
|
|
return false;
|
2003-04-07 20:44:52 +00:00
|
|
|
default:
|
2003-07-12 10:02:12 +00:00
|
|
|
error("Unknown game version %d", _systemVars.gameVersion);
|
2003-04-07 20:44:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
bool SkyEngine::isCDVersion(void) {
|
2003-05-29 03:26:28 +00:00
|
|
|
|
2003-06-01 21:21:10 +00:00
|
|
|
switch (_systemVars.gameVersion) {
|
2003-07-12 10:02:12 +00:00
|
|
|
case 109:
|
2003-04-07 20:44:52 +00:00
|
|
|
case 267:
|
|
|
|
case 288:
|
2003-04-21 14:12:19 +00:00
|
|
|
case 303:
|
2003-04-07 20:44:52 +00:00
|
|
|
case 331:
|
2003-07-04 23:26:46 +00:00
|
|
|
case 348:
|
2003-04-07 20:44:52 +00:00
|
|
|
return false;
|
|
|
|
case 365:
|
|
|
|
case 368:
|
2003-04-08 12:19:15 +00:00
|
|
|
case 372:
|
|
|
|
return true;
|
2003-04-07 20:44:52 +00:00
|
|
|
default:
|
2003-07-12 10:02:12 +00:00
|
|
|
error("Unknown game version %d", _systemVars.gameVersion);
|
2003-04-07 20:44:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-03 01:58:58 +00:00
|
|
|
} // End of namespace Sky
|