2003-03-05 19:04:34 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2003 The ScummVM project
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2003-03-05 21:34:46 +00:00
|
|
|
#include "stdafx.h"
|
2003-09-18 18:23:53 +00:00
|
|
|
|
2003-10-17 23:16:53 +00:00
|
|
|
#include "backends/fs/fs.h"
|
|
|
|
|
2003-09-18 18:23:53 +00:00
|
|
|
#include "base/gameDetector.h"
|
|
|
|
#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"
|
2003-10-05 20:21:20 +00:00
|
|
|
#include "common/timer.h"
|
2003-09-18 18:23:53 +00:00
|
|
|
|
2003-04-25 15:17:53 +00:00
|
|
|
#include "sky/compact.h"
|
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"
|
|
|
|
#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"
|
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
|
|
|
|
2003-07-15 16:40:24 +00:00
|
|
|
extern uint16 _debugLevel;
|
|
|
|
|
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
|
|
|
|
compact(s). Then they did findeth another version, and this was slightly
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2003-07-10 08:24:16 +00:00
|
|
|
#undef WITH_DEBUG_CHEATS
|
|
|
|
|
2003-11-01 16:39:26 +00:00
|
|
|
static const GameSettings skySetting =
|
2003-12-13 00:20:01 +00:00
|
|
|
{"sky", "Beneath a Steel Sky", 0 };
|
2003-03-05 19:04:34 +00:00
|
|
|
|
2003-10-17 23:16:53 +00:00
|
|
|
GameList Engine_SKY_gameList() {
|
|
|
|
GameList games;
|
2003-11-01 16:39:26 +00:00
|
|
|
games.push_back(skySetting);
|
2003-10-17 23:16:53 +00:00
|
|
|
return games;
|
|
|
|
}
|
|
|
|
|
2003-12-21 15:29:52 +00:00
|
|
|
DetectedGameList Engine_SKY_detectGames(const FSList &fslist) {
|
|
|
|
DetectedGameList detectedGames;
|
2003-10-17 23:16:53 +00:00
|
|
|
// Iterate over all files in the given directory
|
|
|
|
for (FSList::ConstIterator file = fslist.begin(); file != fslist.end(); ++file) {
|
2003-11-01 16:02:14 +00:00
|
|
|
const char *fileName = file->displayName().c_str();
|
2003-10-17 23:16:53 +00:00
|
|
|
|
2003-11-01 16:02:14 +00:00
|
|
|
if (0 == scumm_stricmp("sky.dsk", fileName)) {
|
2003-10-17 23:16:53 +00:00
|
|
|
// Match found, add to list of candidates, then abort inner loop.
|
2003-11-01 16:39:26 +00:00
|
|
|
detectedGames.push_back(skySetting);
|
2003-10-17 23:16:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return detectedGames;
|
2003-03-05 19:04:34 +00:00
|
|
|
}
|
|
|
|
|
2003-03-07 14:52:24 +00:00
|
|
|
Engine *Engine_SKY_create(GameDetector *detector, OSystem *syst) {
|
2004-01-03 01:58:58 +00:00
|
|
|
return new Sky::SkyEngine(detector, syst);
|
2003-03-05 19:04:34 +00:00
|
|
|
}
|
|
|
|
|
2003-12-01 09:58:55 +00:00
|
|
|
REGISTER_PLUGIN("Beneath a Steel Sky", Engine_SKY_gameList, Engine_SKY_create, Engine_SKY_detectGames)
|
2003-09-18 18:23:53 +00:00
|
|
|
|
2004-01-03 01:58:58 +00:00
|
|
|
|
|
|
|
namespace Sky {
|
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
void **SkyEngine::_itemList[300];
|
2003-04-25 15:17:53 +00:00
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
SystemVars SkyEngine::_systemVars = {0, 0, 0, 0, 4316, 0, 0, false, false };
|
2003-06-01 21:21:10 +00:00
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
SkyEngine::SkyEngine(GameDetector *detector, OSystem *syst)
|
2003-11-10 01:04:12 +00:00
|
|
|
: Engine(syst) {
|
2003-03-07 14:52:24 +00:00
|
|
|
|
2003-12-24 17:42:22 +00:00
|
|
|
if (!_mixer->isReady())
|
2003-03-12 16:54:30 +00:00
|
|
|
warning("Sound initialisation failed.");
|
2003-03-08 12:46:51 +00:00
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
_mixer->setVolume(ConfMan.getInt("sfx_volume")); //unnecessary?
|
2003-03-08 12:46:51 +00:00
|
|
|
|
2003-10-14 07:52:34 +00:00
|
|
|
_debugMode = ConfMan.hasKey("debuglevel");
|
2003-10-08 21:59:23 +00:00
|
|
|
_debugLevel = ConfMan.getInt("debuglevel");
|
2003-05-21 21:01:12 +00:00
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
_floppyIntro = ConfMan.getBool("floppy_intro");
|
2003-07-29 21:03:25 +00:00
|
|
|
|
2003-08-03 15:50:39 +00:00
|
|
|
_fastMode = 0;
|
|
|
|
|
2003-07-29 21:03:25 +00:00
|
|
|
_system->init_size(320, 200);
|
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
|
|
|
|
|
|
|
delete _skyLogic;
|
|
|
|
delete _skySound;
|
|
|
|
delete _skyMusic;
|
|
|
|
delete _skyText;
|
|
|
|
delete _skyMouse;
|
|
|
|
delete _skyScreen;
|
2003-03-05 19:04:34 +00:00
|
|
|
}
|
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
void SkyEngine::errorString(const char *buf1, char *buf2) {
|
2003-03-07 15:38:11 +00:00
|
|
|
strcpy(buf2, buf1);
|
|
|
|
}
|
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
void SkyEngine::initVirgin() {
|
2003-07-17 00:17:42 +00:00
|
|
|
|
|
|
|
_skyScreen->setPalette(60111);
|
|
|
|
_skyScreen->showScreen(60110);
|
|
|
|
}
|
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
void SkyEngine::doCheat(uint8 num) {
|
2003-07-10 08:24:16 +00:00
|
|
|
|
|
|
|
switch(num) {
|
2003-09-24 06:33:59 +00:00
|
|
|
case 1: warning("executed cheat: get jammer");
|
|
|
|
SkyLogic::_scriptVariables[258] = 42; // got_jammer
|
|
|
|
SkyLogic::_scriptVariables[240] = 69; // got_sponsor
|
|
|
|
break;
|
|
|
|
case 2: warning("executed cheat: computer room");
|
|
|
|
SkyLogic::_scriptVariables[479] = 2; // card_status
|
|
|
|
SkyLogic::_scriptVariables[480] = 1; // card_fix
|
|
|
|
break;
|
|
|
|
case 3: warning("executed cheat: get to burke");
|
|
|
|
SkyLogic::_scriptVariables[190] = 42; // knows_port
|
|
|
|
break;
|
|
|
|
case 4: warning("executed cheat: get to reactor section");
|
|
|
|
SkyLogic::_scriptVariables[451] = 42; // foreman_friend
|
|
|
|
_skyLogic->fnSendSync(8484, 1, 0); // send sync to RAD suit (put in locker)
|
|
|
|
_skyLogic->fnKillId(ID_ANITA_SPY, 0, 0); // stop anita from getting to you
|
|
|
|
break;
|
|
|
|
default: warning("unknown cheat: %d", num);
|
|
|
|
break;
|
2003-07-10 08:24:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
void SkyEngine::handleKey(void) {
|
2003-07-12 02:07:37 +00:00
|
|
|
|
|
|
|
if (_key_pressed == 63)
|
|
|
|
_skyControl->doControlPanel();
|
|
|
|
|
|
|
|
if ((_key_pressed == 27) && (!_systemVars.pastIntro))
|
|
|
|
_skyControl->restartGame();
|
|
|
|
#ifdef WITH_DEBUG_CHEATS
|
|
|
|
if ((_key_pressed >= '0') && (_key_pressed <= '9'))
|
|
|
|
doCheat(_key_pressed - '0');
|
|
|
|
|
|
|
|
if (_key_pressed == 'r') {
|
|
|
|
warning("loading grid");
|
|
|
|
_skyLogic->_skyGrid->loadGrids();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (_key_pressed == '.')
|
|
|
|
_skyMouse->logicClick();
|
|
|
|
_key_pressed = 0;
|
|
|
|
}
|
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
void SkyEngine::go() {
|
2003-03-07 14:52:24 +00:00
|
|
|
|
2003-03-05 19:04:34 +00:00
|
|
|
if (!_dump_file)
|
|
|
|
_dump_file = stdout;
|
|
|
|
|
|
|
|
initialise();
|
2003-04-25 15:17:53 +00:00
|
|
|
|
2003-07-12 05:26:23 +00:00
|
|
|
bool introSkipped = false;
|
|
|
|
if (!_quickLaunch) {
|
2003-07-17 00:17:42 +00:00
|
|
|
if (_systemVars.gameVersion > 267) {// don't do intro for floppydemos
|
|
|
|
_skyIntro = new SkyIntro(_skyDisk, _skyScreen, _skyMusic, _skySound, _skyText, _mixer, _system);
|
|
|
|
introSkipped = !_skyIntro->doIntro(_floppyIntro);
|
|
|
|
if (_skyIntro->_quitProg) {
|
|
|
|
delete _skyIntro;
|
|
|
|
_skyControl->showGameQuitMsg();
|
|
|
|
}
|
|
|
|
delete _skyIntro;
|
|
|
|
}
|
2003-07-12 05:26:23 +00:00
|
|
|
loadBase0();
|
|
|
|
}
|
2003-05-27 16:42:20 +00:00
|
|
|
|
2003-07-10 00:08:07 +00:00
|
|
|
if (introSkipped)
|
|
|
|
_skyControl->restartGame();
|
2003-09-13 01:08:45 +00:00
|
|
|
|
2003-07-11 22:19:16 +00:00
|
|
|
_lastSaveTime = _system->get_msecs();
|
|
|
|
|
2003-03-05 19:04:34 +00:00
|
|
|
while (1) {
|
2003-08-03 15:50:39 +00:00
|
|
|
if (_fastMode & 2)
|
|
|
|
delay(0);
|
|
|
|
else if (_fastMode & 1)
|
|
|
|
delay(10);
|
|
|
|
else
|
|
|
|
delay(_systemVars.gameSpeed);
|
2003-07-11 22:19:16 +00:00
|
|
|
|
|
|
|
if (_system->get_msecs() - _lastSaveTime > 5 * 60 * 1000) {
|
2003-07-31 01:57:05 +00:00
|
|
|
if (_skyControl->loadSaveAllowed()) {
|
2003-07-14 09:16:12 +00:00
|
|
|
_lastSaveTime = _system->get_msecs();
|
|
|
|
_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();
|
2003-06-05 18:54:26 +00:00
|
|
|
_skyMouse->mouseEngine((uint16)_sdl_mouse_x, (uint16)_sdl_mouse_y);
|
2003-07-12 02:07:37 +00:00
|
|
|
if (_key_pressed)
|
|
|
|
handleKey();
|
2003-04-25 15:17:53 +00:00
|
|
|
_skyLogic->engine();
|
2003-07-01 13:04:00 +00:00
|
|
|
if (!_skyLogic->checkProtection()) { // don't let copy prot. screen flash up
|
|
|
|
_skyScreen->recreate();
|
|
|
|
_skyScreen->spriteEngine();
|
|
|
|
_skyScreen->flip();
|
|
|
|
}
|
2003-03-05 19:04:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
void SkyEngine::initialise(void) {
|
2003-04-07 20:44:52 +00:00
|
|
|
_skyDisk = new SkyDisk(_gameDataPath);
|
2003-10-08 21:59:23 +00:00
|
|
|
_skySound = new SkySound(_mixer, _skyDisk, ConfMan.getInt("sfx_volume"));
|
2003-05-03 02:59:45 +00:00
|
|
|
|
2003-06-01 21:21:10 +00:00
|
|
|
_systemVars.gameVersion = _skyDisk->determineGameVersion();
|
2003-05-28 23:31:43 +00:00
|
|
|
|
2003-12-13 00:20:01 +00:00
|
|
|
int midiDriver = GameDetector::detectMusicDriver(MDT_ADLIB | MDT_NATIVE | MDT_PREFER_NATIVE);
|
2003-10-18 00:22:46 +00:00
|
|
|
if (midiDriver == MD_ADLIB) {
|
2003-06-01 21:21:10 +00:00
|
|
|
_systemVars.systemFlags |= SF_SBLASTER;
|
2003-07-01 01:29:29 +00:00
|
|
|
_skyMusic = new SkyAdlibMusic(_mixer, _skyDisk, _system);
|
2003-05-03 02:59:45 +00:00
|
|
|
} else {
|
2003-06-01 21:21:10 +00:00
|
|
|
_systemVars.systemFlags |= SF_ROLAND;
|
2003-10-08 21:59:23 +00:00
|
|
|
if (ConfMan.getBool("native_mt32"))
|
2003-11-10 01:04:12 +00:00
|
|
|
_skyMusic = new SkyMT32Music(GameDetector::createMidi(midiDriver), _skyDisk, _system);
|
2003-06-22 21:42:59 +00:00
|
|
|
else
|
2003-11-10 01:04:12 +00:00
|
|
|
_skyMusic = new SkyGmMusic(GameDetector::createMidi(midiDriver), _skyDisk, _system);
|
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:09:14 +00:00
|
|
|
_systemVars.systemFlags |= SF_ALLOW_SPEECH;
|
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;
|
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
|
|
|
|
2003-06-01 21:21:10 +00:00
|
|
|
_skyText = new SkyText(_skyDisk);
|
2003-06-05 18:54:26 +00:00
|
|
|
_skyMouse = new SkyMouse(_system, _skyDisk);
|
2003-05-14 22:33:39 +00:00
|
|
|
_skyScreen = new SkyScreen(_system, _skyDisk);
|
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();
|
2003-06-02 06:42:42 +00:00
|
|
|
_skyLogic = new SkyLogic(_skyScreen, _skyDisk, _skyText, _skyMusic, _skyMouse, _skySound);
|
2003-06-05 18:54:26 +00:00
|
|
|
_skyMouse->useLogicInstance(_skyLogic);
|
2003-05-14 22:33:39 +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
|
|
|
|
2003-07-04 20:14:11 +00:00
|
|
|
_skyControl = new SkyControl(_skyScreen, _skyDisk, _skyMouse, _skyText, _skyMusic, _skyLogic, _skySound, _system, getSavePath());
|
2003-07-01 13:04:00 +00:00
|
|
|
_skyLogic->useControlInstance(_skyControl);
|
2003-07-03 17:17:32 +00:00
|
|
|
|
|
|
|
if (_systemVars.gameVersion == 288)
|
|
|
|
SkyCompact::patchFor288();
|
2003-07-12 05:26:23 +00:00
|
|
|
|
2003-10-17 15:35:46 +00:00
|
|
|
switch (Common::parseLanguage(ConfMan.get("language"))) {
|
|
|
|
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:
|
2003-07-12 05:38:04 +00:00
|
|
|
_systemVars.language = SKY_USA;
|
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))
|
2003-10-05 20:21:20 +00:00
|
|
|
SkyEngine::_systemVars.language = SKY_ENGLISH;
|
2003-07-12 15:26:07 +00:00
|
|
|
else if (_skyDisk->fileExists(60600 + SKY_USA * 8))
|
2003-10-05 20:21:20 +00:00
|
|
|
SkyEngine::_systemVars.language = SKY_USA;
|
2003-07-12 15:26:07 +00:00
|
|
|
else
|
|
|
|
for (uint8 cnt = SKY_ENGLISH; cnt <= SKY_SPANISH; cnt++)
|
|
|
|
if (_skyDisk->fileExists(60600 + cnt * 8)) {
|
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-07-12 05:26:23 +00:00
|
|
|
uint16 result = 0;
|
2003-10-08 21:59:23 +00:00
|
|
|
if (ConfMan.hasKey("save_slot") && ConfMan.getInt("save_slot") >= 0)
|
|
|
|
result = _skyControl->quickXRestore(ConfMan.getInt("save_slot"));
|
2003-07-12 05:26:23 +00:00
|
|
|
|
|
|
|
if (result == GAME_RESTORED)
|
|
|
|
_quickLaunch = true;
|
|
|
|
else
|
|
|
|
_quickLaunch = false;
|
2003-07-12 06:12:54 +00:00
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
_skyMusic->setVolume(ConfMan.getInt("music_volume") >> 1);
|
2003-04-05 18:01:29 +00:00
|
|
|
}
|
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
void SkyEngine::initItemList() {
|
2003-04-05 18:01:29 +00:00
|
|
|
|
|
|
|
//See List.asm for (cryptic) item # descriptions
|
|
|
|
|
|
|
|
for (int i = 0; i < 300; i++)
|
2003-04-25 15:17:53 +00:00
|
|
|
_itemList[i] = (void **)NULL;
|
2003-04-05 18:01:29 +00:00
|
|
|
|
|
|
|
//init the non-null items
|
2003-04-25 15:17:53 +00:00
|
|
|
_itemList[119] = (void **)SkyCompact::data_0; // Compacts - Section 0
|
|
|
|
_itemList[120] = (void **)SkyCompact::data_1; // Compacts - Section 1
|
2003-04-05 18:01:29 +00:00
|
|
|
|
2003-06-01 21:21:10 +00:00
|
|
|
if (isDemo()) {
|
2003-04-25 15:17:53 +00:00
|
|
|
_itemList[121] = _itemList[122] = _itemList[123] = _itemList[124] = _itemList[125] = (void **)SkyCompact::data_0;
|
2003-04-05 18:01:29 +00:00
|
|
|
} else {
|
2003-04-25 15:17:53 +00:00
|
|
|
_itemList[121] = (void **)SkyCompact::data_2; // Compacts - Section 2
|
|
|
|
_itemList[122] = (void **)SkyCompact::data_3; // Compacts - Section 3
|
|
|
|
_itemList[123] = (void **)SkyCompact::data_4; // Compacts - Section 4
|
|
|
|
_itemList[124] = (void **)SkyCompact::data_5; // Compacts - Section 5
|
|
|
|
_itemList[125] = (void **)SkyCompact::data_6; // Compacts - Section 6
|
2003-04-05 18:01:29 +00:00
|
|
|
}
|
2003-04-25 15:17:53 +00:00
|
|
|
}
|
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
void SkyEngine::loadBase0(void) {
|
2003-05-01 14:10:42 +00:00
|
|
|
|
2003-05-28 20:55:25 +00:00
|
|
|
_skyLogic->fnEnterSection(0, 0, 0);
|
2003-05-01 14:10:42 +00:00
|
|
|
_skyMusic->startMusic(2);
|
2003-07-09 18:12:58 +00:00
|
|
|
_systemVars.currentMusic = 2;
|
2003-05-01 14:10:42 +00:00
|
|
|
}
|
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
void SkyEngine::loadFixedItems(void) {
|
2003-05-01 14:10:42 +00:00
|
|
|
|
2003-06-01 21:21:10 +00:00
|
|
|
if (!isDemo())
|
2003-07-07 06:45:33 +00:00
|
|
|
_itemList[36] = (void **)_skyDisk->loadFile(36, NULL);
|
2003-05-01 14:10:42 +00:00
|
|
|
|
|
|
|
_itemList[49] = (void **)_skyDisk->loadFile(49, NULL);
|
|
|
|
_itemList[50] = (void **)_skyDisk->loadFile(50, NULL);
|
|
|
|
_itemList[73] = (void **)_skyDisk->loadFile(73, NULL);
|
|
|
|
_itemList[262] = (void **)_skyDisk->loadFile(262, NULL);
|
|
|
|
|
2003-06-01 21:21:10 +00:00
|
|
|
if (isDemo())
|
2003-05-01 14:10:42 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
_itemList[263] = (void **)_skyDisk->loadFile(263, NULL);
|
|
|
|
_itemList[264] = (void **)_skyDisk->loadFile(264, NULL);
|
|
|
|
_itemList[265] = (void **)_skyDisk->loadFile(265, NULL);
|
|
|
|
_itemList[266] = (void **)_skyDisk->loadFile(266, NULL);
|
|
|
|
_itemList[267] = (void **)_skyDisk->loadFile(267, NULL);
|
|
|
|
_itemList[269] = (void **)_skyDisk->loadFile(269, NULL);
|
|
|
|
_itemList[271] = (void **)_skyDisk->loadFile(271, NULL);
|
|
|
|
_itemList[272] = (void **)_skyDisk->loadFile(272, NULL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2003-10-05 20:21:20 +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();
|
|
|
|
}
|
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
Compact *SkyEngine::fetchCompact(uint32 a) {
|
2003-04-25 15:17:53 +00:00
|
|
|
SkyDebug::fetchCompact(a);
|
|
|
|
uint32 sectionNum = (a & 0xf000) >> 12;
|
|
|
|
uint32 compactNum = (a & 0x0fff);
|
|
|
|
|
|
|
|
return (Compact *)(_itemList[119 + sectionNum][compactNum]);
|
2003-03-05 19:04:34 +00:00
|
|
|
}
|
|
|
|
|
2003-10-05 20:21:20 +00:00
|
|
|
void SkyEngine::delay(uint amount) { //copied and mutilated from Simon.cpp
|
2003-03-07 14:52:24 +00:00
|
|
|
|
2003-03-05 19:04:34 +00:00
|
|
|
OSystem::Event event;
|
|
|
|
|
|
|
|
uint32 start = _system->get_msecs();
|
|
|
|
uint32 cur = start;
|
2003-04-29 20:42:47 +00:00
|
|
|
_key_pressed = 0; //reset
|
2003-03-05 19:04:34 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
while (_system->poll_event(&event)) {
|
|
|
|
switch (event.event_code) {
|
2003-09-24 06:33:59 +00:00
|
|
|
case OSystem::EVENT_KEYDOWN:
|
|
|
|
if (event.kbd.flags == OSystem::KBD_CTRL) {
|
|
|
|
if (event.kbd.keycode == 'f') {
|
|
|
|
_fastMode ^= 1;
|
|
|
|
break;
|
2003-08-03 15:50:39 +00:00
|
|
|
}
|
2003-09-24 06:33:59 +00:00
|
|
|
if (event.kbd.keycode == 'g') {
|
|
|
|
_fastMode ^= 2;
|
|
|
|
break;
|
2003-07-12 01:12:00 +00:00
|
|
|
}
|
2003-09-24 06:33:59 +00:00
|
|
|
}
|
2003-03-05 19:04:34 +00:00
|
|
|
|
2003-09-24 06:33:59 +00:00
|
|
|
// Make sure backspace works right (this fixes a small issue on OS X)
|
|
|
|
if (event.kbd.keycode == 8)
|
|
|
|
_key_pressed = 8;
|
|
|
|
else
|
|
|
|
_key_pressed = (byte)event.kbd.ascii;
|
|
|
|
break;
|
|
|
|
case OSystem::EVENT_MOUSEMOVE:
|
|
|
|
if (!(_systemVars.systemFlags & SF_MOUSE_LOCKED)) {
|
2003-03-05 19:04:34 +00:00
|
|
|
_sdl_mouse_x = event.mouse.x;
|
|
|
|
_sdl_mouse_y = event.mouse.y;
|
2003-09-24 06:33:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case OSystem::EVENT_LBUTTONDOWN:
|
|
|
|
_skyMouse->buttonPressed(2);
|
|
|
|
#ifdef _WIN32_WCE
|
|
|
|
_sdl_mouse_x = event.mouse.x;
|
|
|
|
_sdl_mouse_y = event.mouse.y;
|
2003-03-05 19:04:34 +00:00
|
|
|
#endif
|
2003-09-24 06:33:59 +00:00
|
|
|
break;
|
|
|
|
case OSystem::EVENT_RBUTTONDOWN:
|
|
|
|
_skyMouse->buttonPressed(1);
|
|
|
|
break;
|
|
|
|
case OSystem::EVENT_QUIT:
|
2003-10-05 20:21:20 +00:00
|
|
|
if (!SkyEngine::_systemVars.quitting)
|
2003-09-24 06:33:59 +00:00
|
|
|
_skyControl->showGameQuitMsg(); // will call _system->quit()
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2003-03-05 19:04:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (amount == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
{
|
|
|
|
uint this_delay = 20; // 1?
|
2003-09-28 22:23:59 +00:00
|
|
|
#ifdef _WIN32_WCE
|
|
|
|
this_delay = 10;
|
|
|
|
#endif
|
2003-03-05 19:04:34 +00:00
|
|
|
if (this_delay > amount)
|
|
|
|
this_delay = amount;
|
|
|
|
_system->delay_msecs(this_delay);
|
|
|
|
}
|
|
|
|
cur = _system->get_msecs();
|
|
|
|
} while (cur < start + amount);
|
|
|
|
}
|
|
|
|
|
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
|