2015-02-06 15:31:43 +01:00
|
|
|
|
2014-05-16 21:58:49 +02: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 "bladerunner/bladerunner.h"
|
|
|
|
|
2015-05-02 22:31:07 +02:00
|
|
|
#include "bladerunner/actor.h"
|
2015-02-06 15:31:43 +01:00
|
|
|
#include "bladerunner/ambient_sounds.h"
|
|
|
|
#include "bladerunner/audio_player.h"
|
2015-02-10 19:33:35 +01:00
|
|
|
#include "bladerunner/audio_speech.h"
|
2014-05-16 21:58:49 +02:00
|
|
|
#include "bladerunner/chapters.h"
|
2015-02-07 17:08:08 +01:00
|
|
|
#include "bladerunner/clues.h"
|
2015-02-06 15:31:43 +01:00
|
|
|
#include "bladerunner/gameflags.h"
|
2015-05-01 09:43:04 +02:00
|
|
|
#include "bladerunner/gameinfo.h"
|
2014-05-16 21:58:49 +02:00
|
|
|
#include "bladerunner/image.h"
|
2015-05-01 09:43:04 +02:00
|
|
|
#include "bladerunner/mouse.h"
|
2014-05-17 17:13:49 +02:00
|
|
|
#include "bladerunner/outtake.h"
|
2014-05-25 15:01:06 +02:00
|
|
|
#include "bladerunner/scene.h"
|
2015-09-13 01:48:13 +02:00
|
|
|
#include "bladerunner/scene_objects.h"
|
2015-02-07 11:41:52 +01:00
|
|
|
#include "bladerunner/script/init.h"
|
2014-05-25 15:01:06 +02:00
|
|
|
#include "bladerunner/script/script.h"
|
2014-05-16 21:58:49 +02:00
|
|
|
#include "bladerunner/settings.h"
|
2015-05-01 09:43:04 +02:00
|
|
|
#include "bladerunner/shape.h"
|
2014-06-05 23:49:57 +02:00
|
|
|
#include "bladerunner/slice_animations.h"
|
|
|
|
#include "bladerunner/slice_renderer.h"
|
2015-02-07 17:08:08 +01:00
|
|
|
#include "bladerunner/text_resource.h"
|
2014-05-16 21:58:49 +02:00
|
|
|
#include "bladerunner/vqa_decoder.h"
|
2015-09-15 20:26:46 +02:00
|
|
|
#include "bladerunner/waypoints.h"
|
|
|
|
#include "bladerunner/items.h"
|
2015-09-19 01:43:38 +02:00
|
|
|
#include "bladerunner/combat.h"
|
2014-05-16 21:58:49 +02:00
|
|
|
|
2015-05-01 09:43:04 +02:00
|
|
|
#include "common/array.h"
|
2014-05-16 21:58:49 +02:00
|
|
|
#include "common/error.h"
|
|
|
|
#include "common/events.h"
|
|
|
|
#include "common/system.h"
|
|
|
|
|
|
|
|
#include "engines/util.h"
|
|
|
|
|
|
|
|
#include "graphics/pixelformat.h"
|
|
|
|
|
|
|
|
namespace BladeRunner {
|
|
|
|
|
2015-02-06 15:31:43 +01:00
|
|
|
BladeRunnerEngine::BladeRunnerEngine(OSystem *syst)
|
|
|
|
: Engine(syst),
|
|
|
|
_rnd("bladerunner")
|
|
|
|
{
|
2014-05-16 21:58:49 +02:00
|
|
|
_windowIsActive = true;
|
|
|
|
_gameIsRunning = true;
|
2015-05-01 10:13:30 +02:00
|
|
|
_playerLosesControlCounter = 0;
|
2014-05-16 21:58:49 +02:00
|
|
|
|
2014-05-25 15:01:06 +02:00
|
|
|
_script = new Script(this);
|
2014-05-16 21:58:49 +02:00
|
|
|
_settings = new Settings(this);
|
2015-09-13 01:48:13 +02:00
|
|
|
_lights = new Lights(this);
|
2015-09-19 01:43:38 +02:00
|
|
|
_combat = new Combat(this);
|
2014-05-16 21:58:49 +02:00
|
|
|
}
|
|
|
|
|
2014-05-30 13:52:59 -07:00
|
|
|
BladeRunnerEngine::~BladeRunnerEngine() {
|
2015-05-02 12:01:47 +02:00
|
|
|
// delete _sliceRenderer;
|
|
|
|
// delete _sliceAnimations;
|
|
|
|
// delete _settings;
|
|
|
|
// delete _script;
|
|
|
|
// delete _scene;
|
|
|
|
// delete[] _gameVars;
|
|
|
|
// delete _gameFlags;
|
|
|
|
// delete _gameInfo;
|
|
|
|
// delete _clues;
|
|
|
|
// delete _chapters;
|
|
|
|
// delete _audioSpeech;
|
|
|
|
// delete _audioPlayer;
|
|
|
|
// delete _ambientSounds;
|
|
|
|
|
|
|
|
// _surface1.free();
|
|
|
|
// _surface2.free();
|
|
|
|
|
|
|
|
// delete[] _zBuffer1;
|
|
|
|
// delete[] _zBuffer2;
|
2015-09-19 01:43:38 +02:00
|
|
|
|
|
|
|
delete _combat;
|
2015-09-15 20:26:46 +02:00
|
|
|
delete _waypoints;
|
2015-09-13 01:48:13 +02:00
|
|
|
delete _lights;
|
2014-05-30 13:52:59 -07:00
|
|
|
delete _settings;
|
|
|
|
delete _script;
|
|
|
|
}
|
|
|
|
|
2014-05-16 21:58:49 +02:00
|
|
|
bool BladeRunnerEngine::hasFeature(EngineFeature f) const {
|
|
|
|
return f == kSupportsRTL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::Error BladeRunnerEngine::run() {
|
2014-05-30 12:45:01 -07:00
|
|
|
Graphics::PixelFormat format = createRGB555();
|
|
|
|
initGraphics(640, 480, true, &format);
|
2014-05-16 21:58:49 +02:00
|
|
|
|
2015-02-06 15:31:43 +01:00
|
|
|
_system->showMouse(true);
|
|
|
|
|
2015-02-10 21:09:12 +01:00
|
|
|
if (!startup()) {
|
|
|
|
shutdown();
|
2014-05-30 10:24:24 -07:00
|
|
|
return Common::Error(Common::kUnknownError, "Failed to initialize resources");
|
2015-02-10 21:09:12 +01:00
|
|
|
}
|
2014-05-16 21:58:49 +02:00
|
|
|
|
2014-05-20 11:30:16 +02:00
|
|
|
if (warnUserAboutUnsupportedGame()) {
|
|
|
|
init2();
|
2014-05-16 21:58:49 +02:00
|
|
|
|
2014-05-20 11:30:16 +02:00
|
|
|
/* TODO: Check for save games and enter KIA */
|
|
|
|
gameLoop();
|
|
|
|
}
|
2014-05-16 21:58:49 +02:00
|
|
|
|
|
|
|
shutdown();
|
|
|
|
|
|
|
|
return Common::kNoError;
|
|
|
|
}
|
|
|
|
|
2015-05-02 12:01:47 +02:00
|
|
|
bool BladeRunnerEngine::startup(bool hasSavegames) {
|
2014-05-16 21:58:49 +02:00
|
|
|
bool r;
|
|
|
|
|
2014-05-30 12:45:01 -07:00
|
|
|
_surface1.create(640, 480, createRGB555());
|
2014-05-16 21:58:49 +02:00
|
|
|
|
|
|
|
r = openArchive("STARTUP.MIX");
|
|
|
|
if (!r)
|
|
|
|
return false;
|
|
|
|
|
2015-05-02 12:01:47 +02:00
|
|
|
// TODO: Timer
|
2014-05-16 21:58:49 +02:00
|
|
|
|
|
|
|
_gameInfo = new GameInfo(this);
|
|
|
|
if (!_gameInfo)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
r = _gameInfo->open("GAMEINFO.DAT");
|
|
|
|
if (!r)
|
|
|
|
return false;
|
|
|
|
|
2015-05-02 12:01:47 +02:00
|
|
|
// TODO: Create graphics surfaces 1-4
|
|
|
|
|
|
|
|
// TODO: Allocate audio cache
|
|
|
|
|
|
|
|
if (hasSavegames) {
|
|
|
|
if (!loadSplash()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-15 20:26:46 +02:00
|
|
|
_waypoints = new Waypoints(this, _gameInfo->getWaypointCount());
|
2015-05-02 12:01:47 +02:00
|
|
|
|
|
|
|
// TODO: Cover waypoints
|
|
|
|
|
|
|
|
// TODO: Flee waypoints
|
2015-02-06 15:31:43 +01:00
|
|
|
|
|
|
|
_gameVars = new int[_gameInfo->getGlobalVarCount()];
|
|
|
|
|
2015-05-02 12:01:47 +02:00
|
|
|
// TODO: Actor AI DLL init
|
|
|
|
|
|
|
|
// Seed rand
|
|
|
|
|
|
|
|
// TODO: Sine and cosine lookup tables for intervals of 1.0, 4.0, and 12.0
|
|
|
|
|
2015-09-13 01:48:13 +02:00
|
|
|
_view = new View(this);
|
2015-05-02 12:01:47 +02:00
|
|
|
|
2015-09-13 01:48:13 +02:00
|
|
|
_sceneObjects = new SceneObjects(this, _view);
|
2015-05-02 12:01:47 +02:00
|
|
|
|
|
|
|
_gameFlags = new GameFlags();
|
|
|
|
_gameFlags->setFlagCount(_gameInfo->getFlagCount());
|
|
|
|
|
2015-09-15 20:26:46 +02:00
|
|
|
_items = new Items(this);
|
2015-05-02 12:01:47 +02:00
|
|
|
|
|
|
|
// Setup sound output
|
|
|
|
|
|
|
|
_audioPlayer = new AudioPlayer(this);
|
|
|
|
|
|
|
|
// TODO: Audio: Music
|
|
|
|
|
|
|
|
_audioSpeech = new AudioSpeech(this);
|
|
|
|
|
|
|
|
_ambientSounds = new AmbientSounds(this);
|
|
|
|
|
|
|
|
// TODO: Read BLADE.INI
|
|
|
|
|
2014-05-16 21:58:49 +02:00
|
|
|
_chapters = new Chapters(this);
|
|
|
|
if (!_chapters)
|
|
|
|
return false;
|
|
|
|
|
2015-05-02 12:01:47 +02:00
|
|
|
if (!openArchive("MUSIC.MIX"))
|
2014-05-16 21:58:49 +02:00
|
|
|
return false;
|
|
|
|
|
2015-05-02 12:01:47 +02:00
|
|
|
if (!openArchive("SFX.MIX"))
|
2014-05-16 21:58:49 +02:00
|
|
|
return false;
|
|
|
|
|
2015-05-02 12:01:47 +02:00
|
|
|
if (!openArchive("SPCHSFX.TLK"))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// TODO: Video overlays
|
|
|
|
|
|
|
|
// TODO: Proper ZBuf class
|
|
|
|
_zBuffer1 = new uint16[640 * 480];
|
|
|
|
_zBuffer2 = new uint16[640 * 480];
|
|
|
|
|
2015-05-02 22:31:07 +02:00
|
|
|
int actorCount = (int)_gameInfo->getActorCount();
|
|
|
|
assert(actorCount < 99);
|
|
|
|
for (int i = 0; i != actorCount; ++i) {
|
|
|
|
_actors[i] = new Actor(this, i);
|
|
|
|
}
|
|
|
|
_voiceoverActor = new Actor(this, 99);
|
|
|
|
_playerActor = _actors[_gameInfo->getPlayerId()];
|
2015-05-02 12:01:47 +02:00
|
|
|
|
2015-05-02 22:31:07 +02:00
|
|
|
// TODO: set _playerActor countdown timer 6
|
2015-05-02 12:01:47 +02:00
|
|
|
|
|
|
|
// TODO: Set actor ids (redundant?)
|
|
|
|
|
|
|
|
// TODO: Police Maze
|
|
|
|
|
|
|
|
_textActorNames = new TextResource(this);
|
|
|
|
if (!_textActorNames->open("ACTORS"))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
_textCrimes = new TextResource(this);
|
|
|
|
if (!_textCrimes->open("CRIMES"))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
_textCluetype = new TextResource(this);
|
|
|
|
if (!_textCluetype->open("CLUETYPE"))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
_textKIA = new TextResource(this);
|
|
|
|
if (!_textKIA->open("KIA"))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
_textSpindest = new TextResource(this);
|
|
|
|
if (!_textSpindest->open("SPINDEST"))
|
2014-05-16 21:58:49 +02:00
|
|
|
return false;
|
|
|
|
|
2015-05-02 12:01:47 +02:00
|
|
|
_textVK = new TextResource(this);
|
|
|
|
if (!_textVK->open("VK"))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
_textOptions = new TextResource(this);
|
|
|
|
if (!_textOptions->open("OPTIONS"))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// TODO: Dialogue Menu (DLGMENU.TRE)
|
|
|
|
|
|
|
|
// TODO: SDB
|
|
|
|
|
|
|
|
// TODO: KIA
|
|
|
|
|
|
|
|
// TODO: Spinner Interface
|
|
|
|
|
|
|
|
// TODO: Elevators
|
|
|
|
|
|
|
|
// TODO: Scores
|
|
|
|
|
|
|
|
// TODO: Font
|
|
|
|
|
|
|
|
// TODO: KIA6PT.FON
|
|
|
|
|
2015-05-01 09:43:04 +02:00
|
|
|
for (int i = 0; i != 43; ++i) {
|
|
|
|
Shape *shape = new Shape(this);
|
|
|
|
shape->readFromContainer("SHAPES.SHP", i);
|
|
|
|
_shapes.push_back(shape);
|
|
|
|
}
|
2015-05-02 12:01:47 +02:00
|
|
|
|
|
|
|
// TODO: Esper
|
|
|
|
|
|
|
|
// TODO: VK
|
|
|
|
|
|
|
|
_mouse = new Mouse(this);
|
|
|
|
// _mouse->setCursorPosition(320, 240);
|
2015-05-01 09:43:04 +02:00
|
|
|
_mouse->setCursor(0);
|
|
|
|
|
2015-05-02 12:01:47 +02:00
|
|
|
_sliceAnimations = new SliceAnimations(this);
|
2014-06-05 23:49:57 +02:00
|
|
|
r = _sliceAnimations->open("INDEX.DAT");
|
|
|
|
if (!r)
|
|
|
|
return false;
|
|
|
|
|
2015-05-02 12:01:47 +02:00
|
|
|
// TODO: Support cdframes
|
2014-06-05 23:49:57 +02:00
|
|
|
|
|
|
|
r = _sliceAnimations->openHDFrames();
|
|
|
|
if (!r)
|
|
|
|
return false;
|
|
|
|
|
2015-05-02 12:01:47 +02:00
|
|
|
r = _sliceAnimations->openCoreAnim();
|
|
|
|
if (!r)
|
|
|
|
return false;
|
2015-02-06 15:31:43 +01:00
|
|
|
|
2015-05-02 12:01:47 +02:00
|
|
|
_sliceRenderer = new SliceRenderer(this);
|
2015-02-07 17:08:08 +01:00
|
|
|
|
|
|
|
_clues = new Clues(this, "CLUES", _gameInfo->getClueCount());
|
|
|
|
|
2015-05-02 12:01:47 +02:00
|
|
|
// TODO: Scene
|
|
|
|
_scene = new Scene(this);
|
|
|
|
|
|
|
|
// Load INIT.DLL
|
2015-02-07 11:41:52 +01:00
|
|
|
ScriptInit initScript(this);
|
|
|
|
initScript.SCRIPT_Initialize_Game();
|
|
|
|
|
2015-05-02 12:01:47 +02:00
|
|
|
// TODO: Load AI-ACT1.DLL
|
|
|
|
|
2014-05-25 15:01:06 +02:00
|
|
|
initChapterAndScene();
|
2014-05-16 21:58:49 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-05-25 15:01:06 +02:00
|
|
|
void BladeRunnerEngine::initChapterAndScene() {
|
2014-05-16 21:58:49 +02:00
|
|
|
// TODO: Init actors...
|
|
|
|
|
|
|
|
_settings->setChapter(1);
|
|
|
|
_settings->setNewSetAndScene(_gameInfo->getInitialSetId(), _gameInfo->getInitialSceneId());
|
|
|
|
}
|
|
|
|
|
|
|
|
void BladeRunnerEngine::shutdown() {
|
2015-02-06 15:31:43 +01:00
|
|
|
_mixer->stopAll();
|
|
|
|
|
2015-05-02 12:01:47 +02:00
|
|
|
// TODO: Write BLADE.INI
|
|
|
|
|
|
|
|
// TODO: Shutdown VK
|
|
|
|
|
|
|
|
// TODO: Shutdown Esper
|
|
|
|
|
|
|
|
delete _mouse;
|
|
|
|
_mouse = 0;
|
|
|
|
|
|
|
|
for (uint i = 0; i != _shapes.size(); ++i) {
|
|
|
|
delete _shapes[i];
|
|
|
|
}
|
|
|
|
_shapes.clear();
|
|
|
|
|
|
|
|
// TODO: Shutdown Scene
|
|
|
|
delete _scene;
|
|
|
|
|
2014-05-16 21:58:49 +02:00
|
|
|
if (_chapters) {
|
|
|
|
if (_chapters->hasOpenResources())
|
|
|
|
_chapters->closeResources();
|
|
|
|
delete _chapters;
|
|
|
|
_chapters = 0;
|
|
|
|
}
|
|
|
|
|
2015-05-02 12:01:47 +02:00
|
|
|
delete _clues;
|
|
|
|
_clues = 0;
|
|
|
|
|
|
|
|
delete _sliceRenderer;
|
|
|
|
_sliceRenderer = 0;
|
|
|
|
|
|
|
|
delete _sliceAnimations;
|
|
|
|
_sliceAnimations = 0;
|
|
|
|
|
|
|
|
delete _textActorNames;
|
|
|
|
_textActorNames = 0;
|
|
|
|
|
|
|
|
delete _textCrimes;
|
|
|
|
_textCrimes = 0;
|
|
|
|
|
|
|
|
delete _textCluetype;
|
|
|
|
_textCluetype = 0;
|
|
|
|
|
|
|
|
delete _textKIA;
|
|
|
|
_textKIA = 0;
|
|
|
|
|
|
|
|
delete _textSpindest;
|
|
|
|
_textSpindest = 0;
|
|
|
|
|
|
|
|
delete _textVK;
|
|
|
|
_textVK = 0;
|
|
|
|
|
|
|
|
delete _textOptions;
|
|
|
|
_textOptions = 0;
|
|
|
|
|
|
|
|
// TODO: Delete dialogue menu
|
|
|
|
|
|
|
|
delete _ambientSounds;
|
|
|
|
|
|
|
|
// TODO: Delete overlays
|
|
|
|
|
|
|
|
delete _audioSpeech;
|
|
|
|
|
|
|
|
// TODO: Delete Audio: Music
|
|
|
|
|
|
|
|
delete _audioPlayer;
|
|
|
|
|
|
|
|
// Shutdown sound output
|
|
|
|
|
2014-05-16 21:58:49 +02:00
|
|
|
if (isArchiveOpen("MUSIC.MIX"))
|
|
|
|
closeArchive("MUSIC.MIX");
|
|
|
|
|
|
|
|
if (isArchiveOpen("SFX.MIX"))
|
|
|
|
closeArchive("SFX.MIX");
|
|
|
|
|
|
|
|
if (isArchiveOpen("SPCHSFX.TLK"))
|
|
|
|
closeArchive("SPCHSFX.TLK");
|
|
|
|
|
2015-05-02 12:01:47 +02:00
|
|
|
// TODO: Delete KIA6PT.FON
|
|
|
|
|
2015-09-19 01:43:38 +02:00
|
|
|
delete _items;
|
|
|
|
_items = 0;
|
2015-05-02 12:01:47 +02:00
|
|
|
|
|
|
|
delete _gameFlags;
|
|
|
|
_gameFlags = 0;
|
|
|
|
|
2015-09-13 01:48:13 +02:00
|
|
|
delete _view;
|
|
|
|
_view = 0;
|
2015-05-02 12:01:47 +02:00
|
|
|
|
2015-09-13 01:48:13 +02:00
|
|
|
delete _sceneObjects;
|
|
|
|
_sceneObjects = 0;
|
2015-05-02 12:01:47 +02:00
|
|
|
|
|
|
|
// TODO: Delete sine and cosine lookup tables
|
|
|
|
|
|
|
|
// TODO: Unload AI dll
|
|
|
|
|
|
|
|
delete[] _gameVars;
|
|
|
|
_gameVars = 0;
|
|
|
|
|
|
|
|
// TODO: Delete World waypoints
|
|
|
|
|
|
|
|
// TODO: Delete Cover waypoints
|
|
|
|
|
|
|
|
// TODO: Delete Flee waypoints
|
|
|
|
|
|
|
|
// TODO: Delete Scores
|
|
|
|
|
|
|
|
// TODO: Delete Elevators
|
|
|
|
|
|
|
|
// TODO: Delete Spinner Interface
|
|
|
|
|
|
|
|
// TODO: Delete KIA
|
|
|
|
|
|
|
|
// TODO: Delete SDB
|
|
|
|
|
|
|
|
// TODO: Delete unknown stuff
|
|
|
|
|
|
|
|
// TODO: Delete actors
|
|
|
|
|
|
|
|
// TODO: Delete proper ZBuf class
|
|
|
|
delete[] _zBuffer1;
|
|
|
|
_zBuffer1 = 0;
|
|
|
|
|
|
|
|
delete[] _zBuffer2;
|
|
|
|
_zBuffer2 = 0;
|
|
|
|
|
|
|
|
delete _gameInfo;
|
|
|
|
_gameInfo = 0;
|
|
|
|
|
|
|
|
// TODO: Delete graphics surfaces here
|
|
|
|
_surface1.free();
|
|
|
|
_surface2.free();
|
|
|
|
|
2014-05-16 21:58:49 +02:00
|
|
|
if (isArchiveOpen("STARTUP.MIX"))
|
|
|
|
closeArchive("STARTUP.MIX");
|
2015-05-02 12:01:47 +02:00
|
|
|
|
|
|
|
// TODO: Delete MIXArchives here
|
|
|
|
|
|
|
|
// TODO: Delete Timer
|
2014-05-16 21:58:49 +02:00
|
|
|
}
|
|
|
|
|
2015-05-02 12:01:47 +02:00
|
|
|
bool BladeRunnerEngine::loadSplash() {
|
2014-05-16 21:58:49 +02:00
|
|
|
Image img(this);
|
|
|
|
if (!img.open("SPLASH.IMG"))
|
2015-05-02 12:01:47 +02:00
|
|
|
return false;
|
2014-05-16 21:58:49 +02:00
|
|
|
|
|
|
|
img.copyToSurface(&_surface1);
|
|
|
|
|
|
|
|
_system->copyRectToScreen(_surface1.getPixels(), _surface1.pitch, 0, 0, _surface1.w, _surface1.h);
|
|
|
|
_system->updateScreen();
|
2015-05-02 12:01:47 +02:00
|
|
|
|
|
|
|
return false;
|
2014-05-16 21:58:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BladeRunnerEngine::init2() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BladeRunnerEngine::gameLoop() {
|
|
|
|
_gameIsRunning = true;
|
|
|
|
do {
|
|
|
|
/* TODO: check player death */
|
|
|
|
gameTick();
|
|
|
|
} while (_gameIsRunning && !shouldQuit());
|
|
|
|
}
|
|
|
|
|
|
|
|
void BladeRunnerEngine::gameTick() {
|
|
|
|
handleEvents();
|
|
|
|
|
|
|
|
if (_gameIsRunning && _windowIsActive) {
|
|
|
|
// TODO: Only run if not in Kia, script, nor AI
|
|
|
|
_settings->openNewScene();
|
|
|
|
|
|
|
|
// TODO: Autosave
|
|
|
|
// TODO: Kia
|
|
|
|
// TODO: Spinner
|
|
|
|
// TODO: Esper
|
|
|
|
// TODO: VK
|
|
|
|
// TODO: Elevators
|
|
|
|
// TODO: Scores
|
|
|
|
// TODO: Call Script_Player_Walked_In if applicable
|
|
|
|
// TODO: Gun range announcements
|
|
|
|
// TODO: ZBUF repair dirty rects
|
2015-02-06 15:31:43 +01:00
|
|
|
|
|
|
|
_ambientSounds->tick();
|
2014-05-16 21:58:49 +02:00
|
|
|
|
2014-05-25 15:01:06 +02:00
|
|
|
bool backgroundChanged = false;
|
2015-02-06 15:31:43 +01:00
|
|
|
int frame = _scene->advanceFrame(_surface1, _zBuffer1);
|
2014-05-25 15:01:06 +02:00
|
|
|
if (frame >= 0) {
|
|
|
|
_script->SceneFrameAdvanced(frame);
|
|
|
|
backgroundChanged = true;
|
|
|
|
}
|
2015-02-06 15:31:43 +01:00
|
|
|
(void)backgroundChanged;
|
2014-06-05 23:49:57 +02:00
|
|
|
_surface2.copyFrom(_surface1);
|
2015-02-06 15:31:43 +01:00
|
|
|
memcpy(_zBuffer2, _zBuffer1, 640*480*2);
|
2014-05-25 15:01:06 +02:00
|
|
|
|
2014-05-16 21:58:49 +02:00
|
|
|
// TODO: Render overlays (mostly in Replicant)
|
|
|
|
// TODO: Tick Actor AI and Timers (timers in Replicant)
|
|
|
|
|
2014-05-25 15:01:06 +02:00
|
|
|
if (_settings->getNewScene() == -1 || _script->_inScriptCounter /* || in_ai */) {
|
2014-05-16 21:58:49 +02:00
|
|
|
|
|
|
|
// TODO: Tick and draw all actors in current set (drawing works in Replicant)
|
2014-06-05 23:49:57 +02:00
|
|
|
|
2015-05-02 22:31:07 +02:00
|
|
|
// HACK to draw McCoy
|
2015-09-13 01:48:13 +02:00
|
|
|
//_sliceRenderer->setView(&_scene->_view);
|
2015-05-02 22:31:07 +02:00
|
|
|
_playerActor->draw();
|
2014-06-05 23:49:57 +02:00
|
|
|
|
2014-05-16 21:58:49 +02:00
|
|
|
// TODO: Draw items (drawing works in Replicant)
|
|
|
|
// TODO: Draw item pickup (understood, drawing works in Replicant)
|
|
|
|
// TODO: Draw dialogue menu
|
2015-05-01 09:43:04 +02:00
|
|
|
|
|
|
|
Common::Point p = _eventMan->getMousePos();
|
2015-09-15 20:26:46 +02:00
|
|
|
_mouse->tick(p.x, p.y);
|
2015-05-01 09:43:04 +02:00
|
|
|
_mouse->draw(_surface2, p.x, p.y);
|
|
|
|
|
2014-05-16 21:58:49 +02:00
|
|
|
// TODO: Process AUD (audio in Replicant)
|
|
|
|
// TODO: Footstep sound
|
|
|
|
|
2014-06-05 23:49:57 +02:00
|
|
|
_system->copyRectToScreen((const byte *)_surface2.getBasePtr(0, 0), _surface2.pitch, 0, 0, 640, 480);
|
2014-05-16 21:58:49 +02:00
|
|
|
_system->updateScreen();
|
2014-05-25 15:01:06 +02:00
|
|
|
_system->delayMillis(10);
|
2014-05-16 21:58:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BladeRunnerEngine::handleEvents() {
|
|
|
|
Common::Event event;
|
|
|
|
Common::EventManager *eventMan = _system->getEventManager();
|
|
|
|
while (eventMan->pollEvent(event)) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-19 01:43:38 +02:00
|
|
|
void BladeRunnerEngine::gameWaitForActive() {
|
|
|
|
while(!_windowIsActive) {
|
|
|
|
handleEvents();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-10 19:33:35 +01:00
|
|
|
void BladeRunnerEngine::loopActorSpeaking() {
|
|
|
|
if (!_audioSpeech->isPlaying())
|
|
|
|
return;
|
|
|
|
|
2015-05-01 10:13:30 +02:00
|
|
|
playerLosesControl();
|
2015-02-10 19:33:35 +01:00
|
|
|
|
|
|
|
do {
|
|
|
|
gameTick();
|
|
|
|
} while (_audioSpeech->isPlaying());
|
|
|
|
|
2015-05-01 10:13:30 +02:00
|
|
|
playerGainsControl();
|
2015-02-10 19:33:35 +01:00
|
|
|
}
|
|
|
|
|
2014-05-17 17:13:49 +02:00
|
|
|
void BladeRunnerEngine::outtakePlay(int id, bool noLocalization, int container) {
|
2014-05-16 21:58:49 +02:00
|
|
|
Common::String name = _gameInfo->getOuttake(id);
|
|
|
|
|
2014-05-17 17:13:49 +02:00
|
|
|
OuttakePlayer player(this);
|
2014-05-16 21:58:49 +02:00
|
|
|
|
2015-02-06 15:31:43 +01:00
|
|
|
player.play(name, noLocalization, container);
|
2014-05-16 21:58:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BladeRunnerEngine::openArchive(const Common::String &name) {
|
|
|
|
uint i;
|
|
|
|
|
|
|
|
// If archive is already open, return true
|
|
|
|
for (i = 0; i != kArchiveCount; ++i) {
|
|
|
|
if (_archives[i].isOpen() && _archives[i].getName() == name)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find first available slot
|
|
|
|
for (i = 0; i != kArchiveCount; ++i) {
|
|
|
|
if (!_archives[i].isOpen())
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i == kArchiveCount) {
|
|
|
|
/* TODO: BLADE.EXE retires the least recently used
|
|
|
|
* archive when it runs out of slots. */
|
|
|
|
|
|
|
|
error("openArchive: No more archive slots");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
_archives[i].open(name);
|
|
|
|
return _archives[i].isOpen();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BladeRunnerEngine::closeArchive(const Common::String &name) {
|
|
|
|
for (uint i = 0; i != 10; ++i) {
|
|
|
|
if (_archives[i].isOpen() &&_archives[i].getName() == name) {
|
|
|
|
_archives[i].close();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
debug("closeArchive: Archive %s not open.", name.c_str());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BladeRunnerEngine::isArchiveOpen(const Common::String &name) {
|
|
|
|
for (uint i = 0; i != 10; ++i) {
|
|
|
|
if (_archives[i].isOpen() &&_archives[i].getName() == name)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::SeekableReadStream *BladeRunnerEngine::getResourceStream(const Common::String &name) {
|
|
|
|
for (uint i = 0; i != 10; ++i) {
|
|
|
|
if (!_archives[i].isOpen())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (false)
|
|
|
|
debug("getResource: Searching archive %s for %s.", _archives[i].getName().c_str(), name.c_str());
|
|
|
|
Common::SeekableReadStream *stream = _archives[i].createReadStreamForMember(name);
|
|
|
|
if (stream)
|
|
|
|
return stream;
|
|
|
|
}
|
|
|
|
|
|
|
|
debug("getResource: Resource %s not found.", name.c_str());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-05-01 10:13:30 +02:00
|
|
|
bool BladeRunnerEngine::playerHasControl() {
|
|
|
|
return _playerLosesControlCounter == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BladeRunnerEngine::playerLosesControl() {
|
|
|
|
if (++_playerLosesControlCounter == 1) {
|
|
|
|
_mouse->disable();
|
|
|
|
}
|
|
|
|
debug("Player Lost Control (%d)", _playerLosesControlCounter);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BladeRunnerEngine::playerGainsControl() {
|
|
|
|
if (_playerLosesControlCounter == 0) {
|
|
|
|
warning("Unbalanced call to BladeRunnerEngine::playerGainsControl");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_playerLosesControlCounter > 0)
|
|
|
|
--_playerLosesControlCounter;
|
|
|
|
|
|
|
|
debug("Player Gained Control (%d)", _playerLosesControlCounter);
|
|
|
|
|
|
|
|
if (_playerLosesControlCounter == 0) {
|
|
|
|
_mouse->enable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-25 19:56:03 +02:00
|
|
|
void BladeRunnerEngine::ISez(const char *str) {
|
|
|
|
debug("\t%s", str);
|
|
|
|
}
|
|
|
|
|
2014-05-16 21:58:49 +02:00
|
|
|
} // End of namespace BladeRunner
|