2003-09-28 15:50:47 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2005-01-01 16:09:25 +00:00
|
|
|
* Copyright (C) 2003-2005 The ScummVM project
|
2003-09-28 15:50:47 +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
|
|
|
|
* 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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2003-09-28 15:50:47 +00:00
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2005-06-24 15:23:51 +00:00
|
|
|
#include "common/stdafx.h"
|
2003-12-01 20:48:41 +00:00
|
|
|
|
2003-10-17 23:16:53 +00:00
|
|
|
#include "backends/fs/fs.h"
|
2003-12-01 20:48:41 +00:00
|
|
|
|
2003-09-28 15:50:47 +00:00
|
|
|
#include "base/gameDetector.h"
|
2003-09-28 17:48:07 +00:00
|
|
|
#include "base/plugins.h"
|
2003-12-01 20:48:41 +00:00
|
|
|
|
2003-10-17 23:16:53 +00:00
|
|
|
#include "common/config-manager.h"
|
|
|
|
#include "common/file.h"
|
2005-01-10 22:06:49 +00:00
|
|
|
#include "common/savefile.h"
|
|
|
|
#include "common/system.h"
|
2003-12-01 20:48:41 +00:00
|
|
|
|
|
|
|
#include "queen/queen.h"
|
2004-01-08 14:10:32 +00:00
|
|
|
#include "queen/bankman.h"
|
2003-10-31 13:47:28 +00:00
|
|
|
#include "queen/command.h"
|
2003-10-17 23:16:53 +00:00
|
|
|
#include "queen/cutaway.h"
|
2003-12-26 12:58:27 +00:00
|
|
|
#include "queen/debug.h"
|
2003-10-16 13:54:48 +00:00
|
|
|
#include "queen/display.h"
|
2003-10-11 10:24:12 +00:00
|
|
|
#include "queen/graphics.h"
|
2004-01-08 14:10:32 +00:00
|
|
|
#include "queen/grid.h"
|
2003-10-23 06:44:35 +00:00
|
|
|
#include "queen/input.h"
|
2003-12-01 20:48:41 +00:00
|
|
|
#include "queen/logic.h"
|
2003-12-14 00:33:21 +00:00
|
|
|
#include "queen/music.h"
|
2003-12-01 20:48:41 +00:00
|
|
|
#include "queen/resource.h"
|
2003-10-21 12:29:37 +00:00
|
|
|
#include "queen/sound.h"
|
2003-10-17 23:16:53 +00:00
|
|
|
#include "queen/talk.h"
|
|
|
|
#include "queen/walk.h"
|
2003-09-28 15:50:47 +00:00
|
|
|
|
2004-01-02 14:21:14 +00:00
|
|
|
#include "sound/mididrv.h"
|
|
|
|
|
2005-08-08 10:59:21 +00:00
|
|
|
#ifdef _WIN32_WCE
|
|
|
|
bool isSmartphone();
|
|
|
|
#endif
|
2003-09-28 15:50:47 +00:00
|
|
|
|
2003-12-12 15:29:58 +00:00
|
|
|
/* Flight of the Amazon Queen */
|
2005-03-06 18:08:46 +00:00
|
|
|
static const GameSettings queen_setting[] = {
|
|
|
|
{ "queen", "Flight of the Amazon Queen", 0 },
|
|
|
|
{ "queen", "Flight of the Amazon Queen (Demo)", 0 },
|
|
|
|
{ "queen", "Flight of the Amazon Queen (Interview)", 0 },
|
|
|
|
{ 0, 0, 0 }
|
|
|
|
};
|
2003-09-28 15:50:47 +00:00
|
|
|
|
2003-10-17 23:16:53 +00:00
|
|
|
GameList Engine_QUEEN_gameList() {
|
|
|
|
GameList games;
|
2005-03-06 18:08:46 +00:00
|
|
|
const GameSettings *g = queen_setting;
|
|
|
|
|
|
|
|
while (g->name) {
|
|
|
|
games.push_back(*g);
|
|
|
|
g++;
|
|
|
|
}
|
2003-10-17 23:16:53 +00:00
|
|
|
return games;
|
|
|
|
}
|
|
|
|
|
2005-03-06 22:35:12 +00:00
|
|
|
GameSettings determineTarget(uint32 size) {
|
2005-04-07 08:57:40 +00:00
|
|
|
switch (size) {
|
|
|
|
case 3724538: //regular demo
|
|
|
|
case 3732177:
|
|
|
|
return queen_setting[1];
|
|
|
|
break;
|
|
|
|
case 1915913: //interview demo
|
|
|
|
return queen_setting[2];
|
|
|
|
break;
|
|
|
|
default: //non-demo
|
|
|
|
return queen_setting[0];
|
|
|
|
break;
|
2005-03-06 18:08:46 +00:00
|
|
|
}
|
2005-03-06 22:35:12 +00:00
|
|
|
return queen_setting[0];
|
2005-03-06 18:08:46 +00:00
|
|
|
}
|
|
|
|
|
2003-12-21 15:29:52 +00:00
|
|
|
DetectedGameList Engine_QUEEN_detectGames(const FSList &fslist) {
|
|
|
|
DetectedGameList detectedGames;
|
2003-10-17 23:16:53 +00:00
|
|
|
|
2003-12-12 15:29:58 +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()) {
|
|
|
|
const char *gameName = file->displayName().c_str();
|
|
|
|
|
|
|
|
if (0 == scumm_stricmp("queen.1", gameName) || 0 == scumm_stricmp("queen.1c", gameName)) {
|
2005-05-10 22:56:25 +00:00
|
|
|
Common::File dataFile;
|
2005-03-06 18:08:46 +00:00
|
|
|
dataFile.open(file->path().c_str());
|
|
|
|
assert(dataFile.isOpen());
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-03-06 18:08:46 +00:00
|
|
|
if (0 == scumm_stricmp("queen.1", gameName)) { //an unmodified file
|
2005-03-06 22:35:12 +00:00
|
|
|
detectedGames.push_back(determineTarget(dataFile.size()));
|
2005-03-06 18:08:46 +00:00
|
|
|
} else if (0 == scumm_stricmp("queen.1c", gameName)) { //oh joy, it's a rebuilt file
|
|
|
|
char header[9];
|
|
|
|
dataFile.read(header, 9);
|
|
|
|
if (0 == scumm_strnicmp("QTBL", header, 4)) { //check validity
|
|
|
|
uint8 version = 0; //default to full/normal version
|
|
|
|
|
|
|
|
if (0 == scumm_strnicmp("PE100", header + 4, 5)) //One of the 2 regular demos
|
|
|
|
version = 1;
|
|
|
|
if (0 == scumm_strnicmp("PEint", header + 4, 5)) //Interview demo
|
|
|
|
version = 2;
|
|
|
|
|
|
|
|
detectedGames.push_back(queen_setting[version]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dataFile.close();
|
2004-12-09 15:06:49 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-10-17 23:16:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return detectedGames;
|
2003-09-28 15:50:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Engine *Engine_QUEEN_create(GameDetector *detector, OSystem *syst) {
|
2003-10-03 19:47:41 +00:00
|
|
|
return new Queen::QueenEngine(detector, syst);
|
2003-09-28 15:50:47 +00:00
|
|
|
}
|
|
|
|
|
2005-03-25 17:55:57 +00:00
|
|
|
REGISTER_PLUGIN(QUEEN, "Flight of the Amazon Queen")
|
2003-09-28 17:48:07 +00:00
|
|
|
|
2003-10-03 19:47:41 +00:00
|
|
|
namespace Queen {
|
|
|
|
|
2003-09-28 15:50:47 +00:00
|
|
|
QueenEngine::QueenEngine(GameDetector *detector, OSystem *syst)
|
2005-09-22 22:55:01 +00:00
|
|
|
: Engine(syst), _debugger(0) {
|
2003-09-28 15:50:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QueenEngine::~QueenEngine() {
|
2003-12-19 09:22:20 +00:00
|
|
|
delete _bam;
|
2003-10-16 13:54:48 +00:00
|
|
|
delete _resource;
|
2004-01-05 13:40:28 +00:00
|
|
|
delete _bankMan;
|
2003-12-11 22:16:35 +00:00
|
|
|
delete _command;
|
2003-12-26 12:58:27 +00:00
|
|
|
delete _debugger;
|
2003-10-16 13:54:48 +00:00
|
|
|
delete _display;
|
2003-10-11 10:24:12 +00:00
|
|
|
delete _graphics;
|
2004-01-08 14:10:32 +00:00
|
|
|
delete _grid;
|
2003-10-23 06:44:35 +00:00
|
|
|
delete _input;
|
2003-12-11 22:16:35 +00:00
|
|
|
delete _logic;
|
2003-12-14 00:33:21 +00:00
|
|
|
delete _music;
|
2003-12-11 22:16:35 +00:00
|
|
|
delete _sound;
|
2004-01-12 13:40:02 +00:00
|
|
|
delete _walk;
|
2003-09-28 15:50:47 +00:00
|
|
|
}
|
|
|
|
|
2004-01-06 16:53:35 +00:00
|
|
|
void QueenEngine::registerDefaultSettings() {
|
|
|
|
ConfMan.registerDefault("music_mute", false);
|
|
|
|
ConfMan.registerDefault("sfx_mute", false);
|
|
|
|
ConfMan.registerDefault("talkspeed", Logic::DEFAULT_TALK_SPEED);
|
2004-12-19 12:19:21 +00:00
|
|
|
ConfMan.registerDefault("speech_mute", _resource->isDemo() || _resource->isInterview());
|
2004-01-06 16:53:35 +00:00
|
|
|
ConfMan.registerDefault("subtitles", true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QueenEngine::checkOptionSettings() {
|
|
|
|
// check talkspeed value
|
2004-12-28 17:20:21 +00:00
|
|
|
if (_talkSpeed < MIN_TEXT_SPEED) {
|
|
|
|
_talkSpeed = MIN_TEXT_SPEED;
|
|
|
|
} else if (_talkSpeed > MAX_TEXT_SPEED) {
|
|
|
|
_talkSpeed = MAX_TEXT_SPEED;
|
2004-01-06 16:53:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ensure text is always on when voice is off
|
|
|
|
if (!_sound->speechOn()) {
|
2004-01-08 10:25:18 +00:00
|
|
|
_subtitles = true;
|
2004-01-06 16:53:35 +00:00
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-12-19 12:19:21 +00:00
|
|
|
// demo and interview versions don't have speech at all
|
|
|
|
if (_sound->speechOn() && (_resource->isDemo() || _resource->isInterview())) {
|
|
|
|
_sound->speechToggle(false);
|
|
|
|
}
|
2004-01-06 16:53:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QueenEngine::readOptionSettings() {
|
2004-03-09 00:52:07 +00:00
|
|
|
_music->setVolume(ConfMan.getInt("music_volume"));
|
2004-01-06 16:53:35 +00:00
|
|
|
_sound->musicToggle(!ConfMan.getBool("music_mute"));
|
|
|
|
_sound->sfxToggle(!ConfMan.getBool("sfx_mute"));
|
2004-01-08 10:25:18 +00:00
|
|
|
_talkSpeed = ConfMan.getInt("talkspeed");
|
2004-12-19 12:19:21 +00:00
|
|
|
_sound->speechToggle(!ConfMan.getBool("speech_mute"));
|
2004-01-08 10:25:18 +00:00
|
|
|
_subtitles = ConfMan.getBool("subtitles");
|
2004-01-06 16:53:35 +00:00
|
|
|
checkOptionSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QueenEngine::writeOptionSettings() {
|
2004-03-09 00:52:07 +00:00
|
|
|
ConfMan.set("music_volume", _music->volume());
|
2004-01-06 16:53:35 +00:00
|
|
|
ConfMan.set("music_mute", !_sound->musicOn());
|
|
|
|
ConfMan.set("sfx_mute", !_sound->sfxOn());
|
2004-01-08 10:25:18 +00:00
|
|
|
ConfMan.set("talkspeed", _talkSpeed);
|
2004-01-06 16:53:35 +00:00
|
|
|
ConfMan.set("speech_mute", !_sound->speechOn());
|
2004-01-08 10:25:18 +00:00
|
|
|
ConfMan.set("subtitles", _subtitles);
|
2004-01-06 16:53:35 +00:00
|
|
|
ConfMan.flushToDisk();
|
|
|
|
}
|
|
|
|
|
2004-01-08 10:25:18 +00:00
|
|
|
void QueenEngine::update(bool checkPlayerInput) {
|
|
|
|
if (_debugger->isAttached()) {
|
|
|
|
_debugger->onFrame();
|
|
|
|
}
|
|
|
|
|
|
|
|
_graphics->update(_logic->currentRoom());
|
|
|
|
_logic->update();
|
|
|
|
|
|
|
|
_input->delay();
|
|
|
|
|
|
|
|
if (!_resource->isInterview()) {
|
|
|
|
_display->palCustomScroll(_logic->currentRoom());
|
|
|
|
}
|
|
|
|
BobSlot *joe = _graphics->bob(0);
|
|
|
|
_display->update(joe->active, joe->x, joe->y);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-01-08 10:25:18 +00:00
|
|
|
_input->checkKeys();
|
|
|
|
if (_input->debugger()) {
|
|
|
|
_input->debuggerReset();
|
|
|
|
_debugger->attach();
|
|
|
|
}
|
2004-12-03 22:39:55 +00:00
|
|
|
if (canLoadOrSave()) {
|
2004-01-08 10:25:18 +00:00
|
|
|
if (_input->quickSave()) {
|
|
|
|
_input->quickSaveReset();
|
2004-01-12 13:40:02 +00:00
|
|
|
saveGameState(0, "Quicksave");
|
2004-01-08 10:25:18 +00:00
|
|
|
}
|
|
|
|
if (_input->quickLoad()) {
|
|
|
|
_input->quickLoadReset();
|
2004-01-12 13:40:02 +00:00
|
|
|
loadGameState(0);
|
2004-01-08 10:25:18 +00:00
|
|
|
}
|
2004-12-03 22:39:55 +00:00
|
|
|
if (_system->getMillis() - _lastSaveTime >= AUTOSAVE_INTERVAL) {
|
2004-12-02 21:24:27 +00:00
|
|
|
saveGameState(AUTOSAVE_SLOT, "Autosave");
|
|
|
|
_lastSaveTime = _system->getMillis();
|
|
|
|
}
|
2004-12-03 22:39:55 +00:00
|
|
|
}
|
|
|
|
if (!_input->cutawayRunning()) {
|
2004-01-08 10:25:18 +00:00
|
|
|
if (checkPlayerInput) {
|
|
|
|
_command->updatePlayer();
|
|
|
|
}
|
|
|
|
if (_input->idleTime() >= Input::DELAY_SCREEN_BLANKER) {
|
|
|
|
_display->blankScreen();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-11 18:07:47 +00:00
|
|
|
bool QueenEngine::canLoadOrSave() const {
|
2004-12-03 22:39:55 +00:00
|
|
|
return !_input->cutawayRunning() && !(_resource->isDemo() || _resource->isInterview());
|
|
|
|
}
|
|
|
|
|
2004-01-12 13:40:02 +00:00
|
|
|
void QueenEngine::saveGameState(uint16 slot, const char *desc) {
|
|
|
|
debug(3, "Saving game to slot %d", slot);
|
|
|
|
char name[20];
|
|
|
|
makeGameStateName(slot, name);
|
2005-05-10 23:17:38 +00:00
|
|
|
Common::OutSaveFile *file = _saveFileMan->openForSaving(name);
|
2004-01-12 13:40:02 +00:00
|
|
|
if (file) {
|
|
|
|
// save data
|
2005-08-11 18:07:47 +00:00
|
|
|
byte *saveData = new byte[SAVESTATE_MAX_SIZE];
|
2004-01-12 13:40:02 +00:00
|
|
|
byte *p = saveData;
|
|
|
|
_bam->saveState(p);
|
|
|
|
_grid->saveState(p);
|
|
|
|
_logic->saveState(p);
|
|
|
|
_sound->saveState(p);
|
|
|
|
uint32 dataSize = p - saveData;
|
2005-08-11 18:07:47 +00:00
|
|
|
assert(dataSize < SAVESTATE_MAX_SIZE);
|
2004-01-12 13:40:02 +00:00
|
|
|
|
|
|
|
// write header
|
|
|
|
GameStateHeader header;
|
|
|
|
memset(&header, 0, sizeof(header));
|
2004-08-24 16:31:46 +00:00
|
|
|
file->writeUint32BE('SCVM');
|
2004-01-12 13:40:02 +00:00
|
|
|
header.version = TO_BE_32(SAVESTATE_CUR_VER);
|
|
|
|
header.flags = TO_BE_32(0);
|
|
|
|
header.dataSize = TO_BE_32(dataSize);
|
|
|
|
strncpy(header.description, desc, sizeof(header.description) - 1);
|
|
|
|
file->write(&header, sizeof(header));
|
|
|
|
|
|
|
|
// write save data
|
2005-11-01 13:56:11 +00:00
|
|
|
file->write(saveData, dataSize);
|
|
|
|
file->flush();
|
|
|
|
|
|
|
|
// check for errors
|
|
|
|
if (file->ioFailed()) {
|
2004-01-12 13:40:02 +00:00
|
|
|
warning("Can't write file '%s'. (Disk full?)", name);
|
|
|
|
}
|
2004-08-06 11:28:33 +00:00
|
|
|
delete[] saveData;
|
2004-01-12 13:40:02 +00:00
|
|
|
delete file;
|
|
|
|
} else {
|
|
|
|
warning("Can't create file '%s', game not saved", name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void QueenEngine::loadGameState(uint16 slot) {
|
|
|
|
debug(3, "Loading game from slot %d", slot);
|
|
|
|
GameStateHeader header;
|
2005-05-10 23:17:38 +00:00
|
|
|
Common::InSaveFile *file = readGameStateHeader(slot, &header);
|
2004-01-12 13:40:02 +00:00
|
|
|
if (file && header.dataSize != 0) {
|
|
|
|
byte *saveData = new byte[header.dataSize];
|
|
|
|
byte *p = saveData;
|
|
|
|
if (file->read(saveData, header.dataSize) != header.dataSize) {
|
|
|
|
warning("Error reading savegame file");
|
|
|
|
} else {
|
|
|
|
_bam->loadState(header.version, p);
|
|
|
|
_grid->loadState(header.version, p);
|
|
|
|
_logic->loadState(header.version, p);
|
|
|
|
_sound->loadState(header.version, p);
|
2004-12-03 22:39:55 +00:00
|
|
|
if (header.dataSize != (uint32)(p - saveData)) {
|
2005-08-11 18:07:47 +00:00
|
|
|
warning("Corrupted savegame file");
|
|
|
|
} else {
|
|
|
|
_logic->setupRestoredGame();
|
2004-12-03 22:39:55 +00:00
|
|
|
}
|
2004-01-12 13:40:02 +00:00
|
|
|
}
|
2004-02-01 13:50:44 +00:00
|
|
|
delete[] saveData;
|
2004-01-12 13:40:02 +00:00
|
|
|
delete file;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-10 23:17:38 +00:00
|
|
|
Common::InSaveFile *QueenEngine::readGameStateHeader(uint16 slot, GameStateHeader *gsh) {
|
2004-01-12 13:40:02 +00:00
|
|
|
char name[20];
|
|
|
|
makeGameStateName(slot, name);
|
2005-05-10 23:17:38 +00:00
|
|
|
Common::InSaveFile *file = _saveFileMan->openForLoading(name);
|
2004-08-24 16:31:46 +00:00
|
|
|
if (file && file->readUint32BE() == 'SCVM') {
|
2004-01-12 13:40:02 +00:00
|
|
|
gsh->version = file->readUint32BE();
|
|
|
|
gsh->flags = file->readUint32BE();
|
|
|
|
gsh->dataSize = file->readUint32BE();
|
|
|
|
file->read(gsh->description, sizeof(gsh->description));
|
|
|
|
} else {
|
|
|
|
memset(gsh, 0, sizeof(GameStateHeader));
|
|
|
|
}
|
|
|
|
return file;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QueenEngine::makeGameStateName(uint16 slot, char *buf) {
|
2004-12-02 21:24:27 +00:00
|
|
|
if (slot == AUTOSAVE_SLOT) {
|
|
|
|
strcpy(buf, "queen.asd");
|
|
|
|
} else {
|
|
|
|
sprintf(buf, "queen.s%02d", slot);
|
|
|
|
}
|
2004-01-12 13:40:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QueenEngine::findGameStateDescriptions(char descriptions[100][32]) {
|
|
|
|
char filename[20];
|
|
|
|
makeGameStateName(0, filename);
|
|
|
|
filename[strlen(filename) - 2] = 0;
|
2005-08-11 18:07:47 +00:00
|
|
|
bool marks[SAVESTATE_MAX_NUM];
|
|
|
|
_saveFileMan->listSavefiles(filename, marks, SAVESTATE_MAX_NUM);
|
|
|
|
for (int i = 0; i < SAVESTATE_MAX_NUM; ++i) {
|
2004-01-12 13:40:02 +00:00
|
|
|
if (marks[i]) {
|
|
|
|
GameStateHeader header;
|
2005-05-10 23:17:38 +00:00
|
|
|
Common::InSaveFile *f = readGameStateHeader(i, &header);
|
2004-01-12 13:40:02 +00:00
|
|
|
strcpy(descriptions[i], header.description);
|
|
|
|
delete f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-28 15:50:47 +00:00
|
|
|
void QueenEngine::errorString(const char *buf1, char *buf2) {
|
|
|
|
strcpy(buf2, buf1);
|
2005-05-09 12:12:14 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32_WCE
|
|
|
|
if (isSmartphone())
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Unless an error -originated- within the debugger, spawn the
|
|
|
|
// debugger. Otherwise exit out normally.
|
|
|
|
if (_debugger && !_debugger->isAttached()) {
|
|
|
|
// (Print it again in case debugger segfaults)
|
|
|
|
printf("%s\n", buf2);
|
|
|
|
_debugger->attach(buf2);
|
|
|
|
_debugger->onFrame();
|
|
|
|
}
|
2003-09-28 15:50:47 +00:00
|
|
|
}
|
|
|
|
|
2004-11-23 00:03:25 +00:00
|
|
|
int QueenEngine::go() {
|
2004-11-23 21:51:30 +00:00
|
|
|
_logic->start();
|
2004-12-03 22:39:55 +00:00
|
|
|
if (ConfMan.hasKey("save_slot") && canLoadOrSave()) {
|
2004-11-30 21:01:25 +00:00
|
|
|
loadGameState(ConfMan.getInt("save_slot"));
|
|
|
|
}
|
2004-12-02 21:24:27 +00:00
|
|
|
_lastSaveTime = _system->getMillis();
|
2004-10-10 17:12:50 +00:00
|
|
|
_quit = false;
|
|
|
|
while (!_quit) {
|
2003-10-16 19:40:29 +00:00
|
|
|
if (_logic->newRoom() > 0) {
|
2003-10-23 06:44:35 +00:00
|
|
|
_logic->update();
|
2003-10-16 19:40:29 +00:00
|
|
|
_logic->oldRoom(_logic->currentRoom());
|
|
|
|
_logic->currentRoom(_logic->newRoom());
|
2003-12-10 15:36:44 +00:00
|
|
|
_logic->changeRoom();
|
2003-11-06 08:44:33 +00:00
|
|
|
_display->fullscreen(false);
|
2003-10-31 13:47:28 +00:00
|
|
|
if (_logic->currentRoom() == _logic->newRoom()) {
|
2003-10-16 19:40:29 +00:00
|
|
|
_logic->newRoom(0);
|
2003-10-31 13:47:28 +00:00
|
|
|
}
|
2004-12-02 22:59:57 +00:00
|
|
|
} else if (_logic->joeWalk() == JWM_EXECUTE) {
|
|
|
|
_logic->joeWalk(JWM_NORMAL);
|
|
|
|
_command->executeCurrentAction();
|
2003-12-29 20:18:31 +00:00
|
|
|
} else {
|
2004-12-02 22:59:57 +00:00
|
|
|
_logic->joeWalk(JWM_NORMAL);
|
|
|
|
update(true);
|
2003-10-16 19:40:29 +00:00
|
|
|
}
|
|
|
|
}
|
2004-11-23 00:03:25 +00:00
|
|
|
return 0;
|
2003-09-28 15:50:47 +00:00
|
|
|
}
|
|
|
|
|
2004-11-24 00:14:21 +00:00
|
|
|
int QueenEngine::init(GameDetector &detector) {
|
|
|
|
_system->beginGFXTransaction();
|
|
|
|
initCommonGFX(detector);
|
|
|
|
_system->initSize(GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT);
|
|
|
|
_system->endGFXTransaction();
|
2004-11-15 19:38:57 +00:00
|
|
|
|
2003-12-19 09:22:20 +00:00
|
|
|
_bam = new BamScene(this);
|
2004-08-06 17:01:58 +00:00
|
|
|
_resource = new Resource();
|
2004-01-05 13:40:28 +00:00
|
|
|
_bankMan = new BankManager(_resource);
|
2003-12-11 22:16:35 +00:00
|
|
|
_command = new Command(this);
|
2003-12-26 12:58:27 +00:00
|
|
|
_debugger = new Debugger(this);
|
2004-01-04 20:25:21 +00:00
|
|
|
_display = new Display(this, _system);
|
2003-12-11 22:16:35 +00:00
|
|
|
_graphics = new Graphics(this);
|
2004-01-08 14:10:32 +00:00
|
|
|
_grid = new Grid(this);
|
2003-11-02 20:42:36 +00:00
|
|
|
_input = new Input(_resource->getLanguage(), _system);
|
2004-01-06 16:53:35 +00:00
|
|
|
|
|
|
|
if (_resource->isDemo()) {
|
|
|
|
_logic = new LogicDemo(this);
|
|
|
|
} else if (_resource->isInterview()) {
|
|
|
|
_logic = new LogicInterview(this);
|
|
|
|
} else {
|
|
|
|
_logic = new LogicGame(this);
|
|
|
|
}
|
2004-01-02 14:21:14 +00:00
|
|
|
|
2004-11-15 19:38:57 +00:00
|
|
|
if (!_mixer->isReady())
|
2005-02-23 17:21:32 +00:00
|
|
|
warning("Sound initialisation failed");
|
2005-05-10 23:48:48 +00:00
|
|
|
_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
|
2004-11-28 23:57:33 +00:00
|
|
|
// Set mixer music volume to maximum, since music volume is regulated by MusicPlayer's MIDI messages
|
2005-05-10 23:48:48 +00:00
|
|
|
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, Audio::Mixer::kMaxMixerVolume);
|
2004-11-15 19:38:57 +00:00
|
|
|
|
2004-12-02 00:33:42 +00:00
|
|
|
int midiDriver = MidiDriver::detectMusicDriver(MDT_NATIVE | MDT_ADLIB | MDT_PREFER_NATIVE);
|
|
|
|
MidiDriver *driver = MidiDriver::createMidi(midiDriver);
|
2004-01-03 02:08:04 +00:00
|
|
|
if (!driver)
|
|
|
|
driver = MidiDriver_ADLIB_create(_mixer);
|
2004-10-22 23:44:08 +00:00
|
|
|
else if (ConfMan.getBool("native_mt32") || (midiDriver == MD_MT32))
|
2004-01-27 23:05:02 +00:00
|
|
|
driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-01-03 02:08:04 +00:00
|
|
|
_music = new Music(driver, this);
|
2004-10-22 23:44:08 +00:00
|
|
|
_music->hasNativeMT32(ConfMan.getBool("native_mt32") || (midiDriver == MD_MT32));
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
_sound = Sound::giveSound(_mixer, this, _resource->compression());
|
|
|
|
_walk = new Walk(this);
|
2004-11-23 00:03:25 +00:00
|
|
|
|
|
|
|
registerDefaultSettings();
|
|
|
|
readOptionSettings();
|
|
|
|
|
|
|
|
return 0;
|
2003-09-28 15:50:47 +00:00
|
|
|
}
|
|
|
|
|
2003-10-03 19:47:41 +00:00
|
|
|
} // End of namespace Queen
|