diff options
author | Peter Kohaut | 2015-09-13 01:48:13 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-09-29 22:33:40 +0200 |
commit | 6672e443a870963354ee43298c75164d382a5636 (patch) | |
tree | 0cee43adb6ac77aa467700f3756668c456bb9af6 /engines/bladerunner | |
parent | a4ba6091316f8f50ea40d4dfd42bd26d419b1206 (diff) | |
download | scummvm-rg350-6672e443a870963354ee43298c75164d382a5636.tar.gz scummvm-rg350-6672e443a870963354ee43298c75164d382a5636.tar.bz2 scummvm-rg350-6672e443a870963354ee43298c75164d382a5636.zip |
BLADERUNNER: just basic objects description scene stuff - lightning and effects movement track actor clues db actor walking info moved view from vqa decoder, because its needed elsewhere
does not compile, because new files are not in makefile...
Diffstat (limited to 'engines/bladerunner')
37 files changed, 1780 insertions, 62 deletions
diff --git a/engines/bladerunner/actor.cpp b/engines/bladerunner/actor.cpp index f483263f76..af9cef7258 100644 --- a/engines/bladerunner/actor.cpp +++ b/engines/bladerunner/actor.cpp @@ -38,7 +38,7 @@ Actor::Actor(BladeRunnerEngine *vm, int actorId) { _bbox = new BoundingBox(); - // TODO: Construct _clues ((actorId && actor != 99) ? 2 : 4) + _clues = new ActorClues(vm, ((actorId && actorId != 99) ? 2 : 4)); // TODO: Construct _movementTrack @@ -69,6 +69,8 @@ void Actor::setup(int actorId) { _isTargetable = false; _isInvisible = false; _isImmuneToObstacles = false; + + _isRetired = false; _width = 0; _height = 0; @@ -105,11 +107,35 @@ void Actor::setup(int actorId) { void Actor::set_at_xyz(Vector3 pos, int facing) { _position = pos; _facing = facing; + + +// this->x = x; +// this->y = y; +// this->z = z; +// actor::set_angle(this, angle, addOrSet); +// if (scene::get_sceneId(Scene) == this->sceneId) +// this->walkboxId = set::findWalkbox(Scene->set, x, z); +// else +// this->walkboxId = -1; +// actor::setBoundingBox(this, x, y, z, retired); +// sceneObjects::removeScreneObject(SceneObjects, this->id); +// scene = this->sceneId; +// if (scene == scene::get_sceneId(Scene)) +// sceneObjects::addActor( +// SceneObjects, +// this->id, +// this->boundingBox, +// &this->screenRect, +// 1, +// a7, +// this->targetable, +// retired); } void Actor::draw() { Vector3 draw_position(_position.x, -_position.z, _position.y + 2.0); float draw_facing = _facing * M_PI / 512.0; + // just for viewing animations _facing = (_facing + 10) % 1024; // float draw_scale = _scale; // TODO: Handle SHORTY mode diff --git a/engines/bladerunner/actor.h b/engines/bladerunner/actor.h index b51bc3fefb..d621d5316a 100644 --- a/engines/bladerunner/actor.h +++ b/engines/bladerunner/actor.h @@ -26,6 +26,11 @@ #include "bladerunner/bladerunner.h" #include "bladerunner/vector.h" +#include "bladerunner/movement_track.h" +#include "bladerunner/actor_clues.h" +#include "bladerunner/actor_walk.h" + +#include "common/rect.h" namespace BladeRunner { @@ -37,7 +42,8 @@ class Actor { private: BoundingBox *_bbox; - // MovementTrack *_movementTrack; + Common::Rect _screenRectangle; + MovementTrack *_movementTrack; int _honesty; int _intelligence; @@ -49,7 +55,7 @@ private: int _currentHP; int _maxHP; - // Clues _clues; + ActorClues* _clues; int _id; int _set; @@ -62,6 +68,8 @@ private: bool _isInvisible; bool _isImmuneToObstacles; + bool _isRetired; + // Animation int _width; int _height; @@ -71,7 +79,7 @@ private: int _animationId; int _animationFrame; - // WalkInfo _walkInfo; + ActorWalk* _walkInfo; int _timersRemain[7]; int _timersBegan[7]; @@ -87,6 +95,12 @@ public: void set_at_xyz(Vector3 pos, int facing); void draw(); + + int getSet() { return _set; } + BoundingBox* getBoundingBox() { return _bbox; } + Common::Rect* getScreenRectangle() { return &_screenRectangle; } + bool isRetired() { return _isRetired; } + bool isTargetable() { return _isTargetable; } }; } // End of namespace BladeRunner diff --git a/engines/bladerunner/actor_clues.cpp b/engines/bladerunner/actor_clues.cpp new file mode 100644 index 0000000000..f99b6b1d61 --- /dev/null +++ b/engines/bladerunner/actor_clues.cpp @@ -0,0 +1,181 @@ +#include "bladerunner/actor_clues.h" + +namespace BladeRunner +{ + + ActorClues::ActorClues(BladeRunnerEngine *vm, int cluesType) + { + _vm = vm; + _count = 0; + _maxCount = 0; + _clues = 0; + switch (cluesType) + { + case 4: + _maxCount = _vm->_gameInfo->getClueCount(); + break; + case 3: + _maxCount = 100; + break; + case 2: + _maxCount = 50; + break; + case 1: + _maxCount = 25; + break; + case 0: + _maxCount = 0; + break; + default: + return; + } + + if (_maxCount > 0) + _clues = new ActorClue[_maxCount]; + else + _clues = NULL; + + if (_clues) + removeAll(); + else + _maxCount = NULL; + } + + ActorClues::~ActorClues() + { + if (_clues) + delete[] _clues; + + _maxCount = 0; + _count = 0; + } + + void ActorClues::acquire(int clueId, char flag2, int fromActorId) + { + int clueIndex = findClueIndex(clueId); + _clues[clueIndex]._flags |= 0x01; + _clues[_count]._flags = _clues[_count]._flags & 0xFD | ((flag2 << 1) & 0x02); + _clues[clueIndex]._fromActorId = fromActorId; + } + + void ActorClues::lose(int clueId) + { + int clueIndex = findClueIndex(clueId); + _clues[clueIndex]._flags = 0; + } + + int ActorClues::isAcquired(int clueId) + { + int clueIndex = findClueIndex(clueId); + if (clueIndex == -1) + return 0; + + return _clues[clueIndex]._flags & 0x01; + } + + int ActorClues::getFromActorId(int clueId) + { + int clueIndex = findClueIndex(clueId); + if (clueIndex == -1) + return -1; + + return _clues[clueIndex]._fromActorId; + } + + int ActorClues::isFlag2(int clueId) + { + int clueIndex = findClueIndex(clueId); + if (clueIndex == -1) + return 0; + + return (_clues[clueIndex]._flags & 0x02) >> 1; + } + + int ActorClues::isFlag3(int clueId) + { + int clueIndex = findClueIndex(clueId); + if (clueIndex == -1) + return 0; + + return (_clues[clueIndex]._flags & 0x04) >> 2; + } + + int ActorClues::isFlag4(int clueId) + { + int clueIndex = findClueIndex(clueId); + if (clueIndex == -1) + return 0; + + return (_clues[clueIndex]._flags & 0x08) >> 3; + } + + int ActorClues::getField1(int clueId) + { + if (!_count) + return 0; + + int clueIndex = findClueIndex(clueId); + if (clueIndex == -1) + return 0; + + return _clues[clueIndex]._field1; + } + + int ActorClues::getCount() + { + return _count; + } + + void ActorClues::removeAll() + { + _count = 0; + for (int i = 0; i < _maxCount; ++i) { + remove(i); + } + } + + int ActorClues::findClueIndex(int clueId) + { + for (int i = 0; i < _count; i++) { + if (clueId == _clues[i]._clueId) { + return i; + } + } + return -1; + } + + void ActorClues::add(int actorId, int clueId, int field1, char acquired, char flag2, int fromActorId) + { + _clues[_count]._clueId = clueId; + _clues[_count]._field1 = field1; + + _clues[_count]._flags = 0; + _clues[_count]._flags = _clues[_count]._flags & 0xFE | (acquired & 0x01); + _clues[_count]._flags = _clues[_count]._flags & 0xFD | ((flag2 << 1) & 0x02); + + _clues[_count]._fromActorId = fromActorId; + ++_count; + } + + void ActorClues::remove(int index) + { + _clues[index]._clueId = -1; + _clues[index]._field1 = 0; + _clues[index]._flags = 0; + _clues[index]._fromActorId = -1; + + _clues[index]._field3 = -1; + _clues[index]._field4 = 0; + _clues[index]._field5 = -1; + _clues[index]._field6 = 0; + _clues[index]._field7 = -1; + _clues[index]._field8 = 0; + } + + int ActorClues::exists(int clueId) + { + return findClueIndex(clueId) != -1; + } + + +}
\ No newline at end of file diff --git a/engines/bladerunner/actor_clues.h b/engines/bladerunner/actor_clues.h new file mode 100644 index 0000000000..02d6bbb1ca --- /dev/null +++ b/engines/bladerunner/actor_clues.h @@ -0,0 +1,82 @@ +/* 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. +* +*/ + +#ifndef BLADERUNNER_ACTOR_CLUES_H +#define BLADERUNNER_ACTOR_CLUES_H + +#include "bladerunner/bladerunner.h" + +#include "bladerunner/gameinfo.h" + +namespace BladeRunner { + + struct ActorClue + { + int _clueId; + int _field1; + int _fromActorId; + int _field3; + int _field4; + int _field5; + int _field6; + int _field7; + int _field8; + unsigned char _flags; + }; + + class ActorClues + { + BladeRunnerEngine *_vm; + + private: + int _count; + int _maxCount; + ActorClue *_clues; + + public: + ActorClues(BladeRunnerEngine *_vm, int cluesType); + ~ActorClues(); + + void acquire(int clueId, char flag2, int fromActorId); + void lose(int clueId); + int isAcquired(int clueId); + int getFromActorId(int clueId); + int isFlag2(int clueId); + int isFlag3(int clueId); + int isFlag4(int clueId); + int getField1(int clueId); + + int getCount(); + + void removeAll(); + + //savegame + //loadgame + private: + int findClueIndex(int clueId); + void add(int actorId, int clueId, int field1, char acquired, char flag2, int fromActorId); + void remove(int clueIndex); + int exists(int clueId); + }; +} + +#endif diff --git a/engines/bladerunner/actor_walk.cpp b/engines/bladerunner/actor_walk.cpp new file mode 100644 index 0000000000..a4cfad7fde --- /dev/null +++ b/engines/bladerunner/actor_walk.cpp @@ -0,0 +1,8 @@ +#include "bladerunner/actor_walk.h" + +namespace BladeRunner +{ + + + +}
\ No newline at end of file diff --git a/engines/bladerunner/actor_walk.h b/engines/bladerunner/actor_walk.h new file mode 100644 index 0000000000..c44c15bbe4 --- /dev/null +++ b/engines/bladerunner/actor_walk.h @@ -0,0 +1,52 @@ +/* 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. +* +*/ + +#ifndef BLADERUNNER_ACTOR_WALK_H +#define BLADERUNNER_ACTOR_WALK_H + +#include "bladerunner/vector.h" + +namespace BladeRunner +{ + struct ActorWalkEntry + { + int _actorId; + int _present; + }; + + class ActorWalk + { + int _walking; + int _running; + Vector3 _wanted; + Vector3 _unknown; + Vector3 _start; + Vector3 _end; + int facing; + ActorWalkEntry _actors[20]; + int _actorsCount; + int _field15; + int _status; + }; +} + +#endif diff --git a/engines/bladerunner/audio_player.cpp b/engines/bladerunner/audio_player.cpp index ecfc95aaa7..b8df01cd85 100644 --- a/engines/bladerunner/audio_player.cpp +++ b/engines/bladerunner/audio_player.cpp @@ -165,7 +165,7 @@ void AudioPlayer::fadeAndStopTrack(Track *track, int time) int AudioPlayer::playAud(const Common::String &name, int volume, int panFrom, int panTo, int priority, byte flags) { /* Find first available track or, alternatively, the lowest priority playing track */ - int trackId; + int trackId = -1; Track *track = NULL; int lowestPriority = 100; Track *lowestPriorityTrack = NULL; diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp index ca83ac9a19..22199e6fd7 100644 --- a/engines/bladerunner/bladerunner.cpp +++ b/engines/bladerunner/bladerunner.cpp @@ -35,6 +35,7 @@ #include "bladerunner/mouse.h" #include "bladerunner/outtake.h" #include "bladerunner/scene.h" +#include "bladerunner/scene_objects.h" #include "bladerunner/script/init.h" #include "bladerunner/script/script.h" #include "bladerunner/settings.h" @@ -65,6 +66,7 @@ BladeRunnerEngine::BladeRunnerEngine(OSystem *syst) _script = new Script(this); _settings = new Settings(this); + _lights = new Lights(this); } BladeRunnerEngine::~BladeRunnerEngine() { @@ -87,7 +89,7 @@ BladeRunnerEngine::~BladeRunnerEngine() { // delete[] _zBuffer1; // delete[] _zBuffer2; - + delete _lights; delete _settings; delete _script; } @@ -162,9 +164,9 @@ bool BladeRunnerEngine::startup(bool hasSavegames) { // TODO: Sine and cosine lookup tables for intervals of 1.0, 4.0, and 12.0 - // TODO: View + _view = new View(this); - // TODO: Screen Index + _sceneObjects = new SceneObjects(this, _view); _gameFlags = new GameFlags(); _gameFlags->setFlagCount(_gameInfo->getFlagCount()); @@ -401,9 +403,11 @@ void BladeRunnerEngine::shutdown() { delete _gameFlags; _gameFlags = 0; - // TODO: Delete View + delete _view; + _view = 0; - // TODO: Delete Screen Index + delete _sceneObjects; + _sceneObjects = 0; // TODO: Delete sine and cosine lookup tables @@ -517,7 +521,7 @@ void BladeRunnerEngine::gameTick() { // TODO: Tick and draw all actors in current set (drawing works in Replicant) // HACK to draw McCoy - _sliceRenderer->setView(_scene->_view); + //_sliceRenderer->setView(&_scene->_view); _playerActor->draw(); // TODO: Draw items (drawing works in Replicant) diff --git a/engines/bladerunner/bladerunner.h b/engines/bladerunner/bladerunner.h index d0ded00b76..814041d0ed 100644 --- a/engines/bladerunner/bladerunner.h +++ b/engines/bladerunner/bladerunner.h @@ -46,12 +46,16 @@ class GameInfo; class GameFlags; class Mouse; class Scene; +class SceneObjects; class Script; class Settings; class Shape; class SliceAnimations; class SliceRenderer; class TextResource; +class Lights; +class View; + class BladeRunnerEngine : public Engine { public: @@ -67,13 +71,17 @@ public: GameFlags *_gameFlags; GameInfo *_gameInfo; Mouse *_mouse; + View *_view; Scene *_scene; + SceneObjects *_sceneObjects; Script *_script; Settings *_settings; SliceAnimations *_sliceAnimations; SliceRenderer *_sliceRenderer; int *_gameVars; + Lights *_lights; + TextResource *_textActorNames; TextResource *_textCrimes; TextResource *_textCluetype; diff --git a/engines/bladerunner/boundingbox.cpp b/engines/bladerunner/boundingbox.cpp index 10e529b1e3..fb2ae94813 100644 --- a/engines/bladerunner/boundingbox.cpp +++ b/engines/bladerunner/boundingbox.cpp @@ -34,4 +34,23 @@ BoundingBox::BoundingBox(float x0, float y0, float z0, float x1, float y1, float _vertices[1].z = z1; } +void BoundingBox::expand(float x0, float y0, float z0, float x1, float y1, float z1) +{ + _vertices[0].x += x0; + _vertices[0].y += y0; + _vertices[0].z += z0; + + _vertices[1].x += x1; + _vertices[1].y += y1; + _vertices[1].z += z1; +} + + +bool BoundingBox::isXYZInside(float x, float y, float z) +{ + return + x >= _vertices[0].x && x <= _vertices[1].x + && y >= _vertices[0].y && y <= _vertices[1].y + && z >= _vertices[0].z && z <= _vertices[1].z; +} } // End of namespace BladeRunner diff --git a/engines/bladerunner/boundingbox.h b/engines/bladerunner/boundingbox.h index 5dda3f0e3f..1766973f26 100644 --- a/engines/bladerunner/boundingbox.h +++ b/engines/bladerunner/boundingbox.h @@ -28,11 +28,15 @@ namespace BladeRunner { class BoundingBox { +public: Vector3 _vertices[2]; public: BoundingBox() {} BoundingBox(float x0, float y0, float z0, float x1, float y1, float z1); + + void expand(float x0, float y0, float z0, float x1, float y1, float z1); + bool isXYZInside(float x, float y, float z); }; } // End of namespace BladeRunner diff --git a/engines/bladerunner/color.h b/engines/bladerunner/color.h new file mode 100644 index 0000000000..54983b401b --- /dev/null +++ b/engines/bladerunner/color.h @@ -0,0 +1,37 @@ +/* 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. +* +*/ + +#ifndef BLADERUNNER_COLOR_H +#define BLADERUNNER_COLOR_H + +namespace BladeRunner { + + struct Color + { + float r; + float g; + float b; + }; +} + + +#endif diff --git a/engines/bladerunner/fog.cpp b/engines/bladerunner/fog.cpp new file mode 100644 index 0000000000..5951ba8d1c --- /dev/null +++ b/engines/bladerunner/fog.cpp @@ -0,0 +1,94 @@ +#include "bladerunner/fog.h" + +namespace BladeRunner +{ + Fog::Fog() + { + } + + Fog::~Fog() + { + } + + int Fog::readCommon(Common::ReadStream* stream) + { + int offset = stream->readUint32LE(); + stream->read(_name, 20); + _fogColor.r = stream->readFloatLE(); + _fogColor.g = stream->readFloatLE(); + _fogColor.b = stream->readFloatLE(); + _fogDensity = stream->readFloatLE(); + return offset; + } + + + void Fog::readAnimationData(Common::ReadStream* stream, int size) + { + _animatedParameters = stream->readUint32LE(); + _animationData = new float[size / sizeof(float)]; + stream->read(_animationData, size); + + _m11ptr = _animationData; + _m12ptr = _m11ptr + (_animatedParameters & 0x1 ? _framesCount : 1); + _m13ptr = _m12ptr + (_animatedParameters & 0x2 ? _framesCount : 1); + _m14ptr = _m13ptr + (_animatedParameters & 0x4 ? _framesCount : 1); + _m21ptr = _m14ptr + (_animatedParameters & 0x08 ? _framesCount : 1); + _m22ptr = _m21ptr + (_animatedParameters & 0x10 ? _framesCount : 1); + _m23ptr = _m22ptr + (_animatedParameters & 0x20 ? _framesCount : 1); + _m24ptr = _m23ptr + (_animatedParameters & 0x40 ? _framesCount : 1); + _m31ptr = _m24ptr + (_animatedParameters & 0x80 ? _framesCount : 1); + _m32ptr = _m31ptr + (_animatedParameters & 0x100 ? _framesCount : 1); + _m33ptr = _m32ptr + (_animatedParameters & 0x200 ? _framesCount : 1); + _m34ptr = _m33ptr + (_animatedParameters & 0x400 ? _framesCount : 1); + + setupFrame(0); + } + + void Fog::reset() + { + } + + void Fog::setupFrame(int frame) + { + int offset = frame % _framesCount; + _matrix._m[0][0] = (_animatedParameters & 0x1 ? _m11ptr[offset] : *_m11ptr); + _matrix._m[0][1] = (_animatedParameters & 0x2 ? _m12ptr[offset] : *_m12ptr); + _matrix._m[0][2] = (_animatedParameters & 0x4 ? _m13ptr[offset] : *_m13ptr); + _matrix._m[0][3] = (_animatedParameters & 0x8 ? _m14ptr[offset] : *_m14ptr); + _matrix._m[1][0] = (_animatedParameters & 0x10 ? _m21ptr[offset] : *_m21ptr); + _matrix._m[1][1] = (_animatedParameters & 0x20 ? _m22ptr[offset] : *_m22ptr); + _matrix._m[1][2] = (_animatedParameters & 0x40 ? _m23ptr[offset] : *_m23ptr); + _matrix._m[1][3] = (_animatedParameters & 0x80 ? _m24ptr[offset] : *_m24ptr); + _matrix._m[2][0] = (_animatedParameters & 0x100 ? _m31ptr[offset] : *_m31ptr); + _matrix._m[2][1] = (_animatedParameters & 0x200 ? _m32ptr[offset] : *_m32ptr); + _matrix._m[2][2] = (_animatedParameters & 0x400 ? _m33ptr[offset] : *_m33ptr); + _matrix._m[2][3] = (_animatedParameters & 0x800 ? _m34ptr[offset] : *_m34ptr); + _inverted = invertMatrix(_matrix); + } + + void FogCone::read(Common::ReadStream* stream, int framesCount) + { + _framesCount = framesCount; + int size = readCommon(stream); + _parameter1 = stream->readFloatLE(); + readAnimationData(stream, size - 52); + } + + void FogSphere::read(Common::ReadStream* stream, int framesCount) + { + _framesCount = framesCount; + int size = readCommon(stream); + _parameter1 = stream->readFloatLE(); + readAnimationData(stream, size - 52); + } + + void FogBox::read(Common::ReadStream* stream, int framesCount) + { + _framesCount = framesCount; + int size = readCommon(stream); + _parameter1 = stream->readFloatLE(); + _parameter2 = stream->readFloatLE(); + _parameter3 = stream->readFloatLE(); + readAnimationData(stream, size - 60); + } +}
\ No newline at end of file diff --git a/engines/bladerunner/fog.h b/engines/bladerunner/fog.h new file mode 100644 index 0000000000..627e8f15bd --- /dev/null +++ b/engines/bladerunner/fog.h @@ -0,0 +1,104 @@ +/* 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. +* +*/ + +#ifndef BLADERUNNER_FOG_H +#define BLADERUNNER_FOG_H + +#include "bladerunner/bladerunner.h" +#include "bladerunner/color.h" +#include "bladerunner/matrix.h" + +#include "common/stream.h" + + +namespace BladeRunner { + + class SetEffects; + + class Fog + { + friend class SetEffects; + + protected: + char _name[20]; + int _framesCount; + int _animatedParameters; + Matrix4x3 _matrix; + Matrix4x3 _inverted; + Color _fogColor; + float _fogDensity; + float *_animationData; + float *_m11ptr; + float *_m12ptr; + float *_m13ptr; + float *_m14ptr; + float *_m21ptr; + float *_m22ptr; + float *_m23ptr; + float *_m24ptr; + float *_m31ptr; + float *_m32ptr; + float *_m33ptr; + float *_m34ptr; + + float _parameter1; + float _parameter2; + float _parameter3; + + Fog *_next; + + public: + Fog(); + ~Fog(); + + virtual void read(Common::ReadStream *stream, int framesCount) = 0; + + void reset(); + + void setupFrame(int frame); + + private: + protected: + int readCommon(Common::ReadStream *stream); + void readAnimationData(Common::ReadStream *stream, int count); + + }; + + class FogCone : public Fog + { + void read(Common::ReadStream *stream, int framesCount); + }; + + class FogSphere : public Fog + { + void read(Common::ReadStream *stream, int framesCount); + }; + + class FogBox : public Fog + { + void read(Common::ReadStream *stream, int framesCount); + }; + + + +} +#endif diff --git a/engines/bladerunner/light.cpp b/engines/bladerunner/light.cpp new file mode 100644 index 0000000000..6bc97f8392 --- /dev/null +++ b/engines/bladerunner/light.cpp @@ -0,0 +1,84 @@ +#include "bladerunner/light.h" + +namespace BladeRunner +{ + Light::Light() + { + } + + Light::~Light() + { + } + + void Light::read(Common::ReadStream* stream, int framesCount, int frame, int animated) + { + _framesCount = framesCount; + _animated = animated; + + int size = stream->readUint32LE(); + size = size - 32; + + stream->read(_name, 20); + + _animatedParameters = stream->readUint32LE(); + + _animationData = new float[size / sizeof(float)]; + stream->read(_animationData, size); + + _m11ptr = _animationData; + _m12ptr = _m11ptr + (_animatedParameters & 0x1 ? framesCount : 1); + _m13ptr = _m12ptr + (_animatedParameters & 0x2 ? framesCount : 1); + _m14ptr = _m13ptr + (_animatedParameters & 0x4 ? framesCount : 1); + _m21ptr = _m14ptr + (_animatedParameters & 0x8 ? framesCount : 1); + _m22ptr = _m21ptr + (_animatedParameters & 0x10 ? framesCount : 1); + _m23ptr = _m22ptr + (_animatedParameters & 0x20 ? framesCount : 1); + _m24ptr = _m23ptr + (_animatedParameters & 0x40 ? framesCount : 1); + _m31ptr = _m24ptr + (_animatedParameters & 0x80 ? framesCount : 1); + _m32ptr = _m31ptr + (_animatedParameters & 0x100 ? framesCount : 1); + _m33ptr = _m32ptr + (_animatedParameters & 0x200 ? framesCount : 1); + _m34ptr = _m33ptr + (_animatedParameters & 0x400 ? framesCount : 1); + _colorRPtr = _m34ptr + (_animatedParameters & 0x800 ? framesCount : 1); + _colorGPtr = _colorRPtr + (_animatedParameters & 0x1000 ? framesCount : 1); + _colorBPtr = _colorGPtr + (_animatedParameters & 0x2000 ? framesCount : 1); + _field16ptr = _colorGPtr + (_animatedParameters & 0x4000 ? framesCount : 1); + _field17ptr = _field16ptr + (_animatedParameters & 0x8000 ? framesCount : 1); + _field18ptr = _field17ptr + (_animatedParameters & 0x10000 ? framesCount : 1); + _field19ptr = _field18ptr + (_animatedParameters & 0x20000 ? framesCount : 1); + + setupFrame(frame); + } + + void Light::readVqa(Common::ReadStream* stream) + { + } + + void Light::setupFrame(int frame) + { + int offset = frame % _framesCount; + _matrix._m[0][0] = (_animatedParameters & 0x1 ? _m11ptr[offset] : *_m11ptr); + _matrix._m[0][1] = (_animatedParameters & 0x2 ? _m12ptr[offset] : *_m12ptr); + _matrix._m[0][2] = (_animatedParameters & 0x4 ? _m13ptr[offset] : *_m13ptr); + _matrix._m[0][3] = (_animatedParameters & 0x8 ? _m14ptr[offset] : *_m14ptr); + _matrix._m[1][0] = (_animatedParameters & 0x10 ? _m21ptr[offset] : *_m21ptr); + _matrix._m[1][1] = (_animatedParameters & 0x20 ? _m22ptr[offset] : *_m22ptr); + _matrix._m[1][2] = (_animatedParameters & 0x40 ? _m23ptr[offset] : *_m23ptr); + _matrix._m[1][3] = (_animatedParameters & 0x80 ? _m24ptr[offset] : *_m24ptr); + _matrix._m[2][0] = (_animatedParameters & 0x100 ? _m31ptr[offset] : *_m31ptr); + _matrix._m[2][1] = (_animatedParameters & 0x200 ? _m32ptr[offset] : *_m32ptr); + _matrix._m[2][2] = (_animatedParameters & 0x400 ? _m33ptr[offset] : *_m33ptr); + _matrix._m[2][3] = (_animatedParameters & 0x800 ? _m34ptr[offset] : *_m34ptr); + _color.r = (_animatedParameters & 0x1000 ? _colorRPtr[offset] : *_colorRPtr); + _color.g = (_animatedParameters & 0x2000 ? _colorGPtr[offset] : *_colorGPtr); + _color.b = (_animatedParameters & 0x4000 ? _colorBPtr[offset] : *_colorBPtr); + _field16 = (_animatedParameters & 0x8000 ? _field16ptr[offset] : *_field16ptr); + _field17 = (_animatedParameters & 0x10000 ? _field17ptr[offset] : *_field17ptr); + _field18 = (_animatedParameters & 0x20000 ? _field18ptr[offset] : *_field18ptr); + _field19 = (_animatedParameters & 0x40000 ? _field19ptr[offset] : *_field19ptr); + + } + + float Light::attenuation(float min, float max, float distance) + { + return 0.0; + } +}
\ No newline at end of file diff --git a/engines/bladerunner/light.h b/engines/bladerunner/light.h new file mode 100644 index 0000000000..f4c142e4ab --- /dev/null +++ b/engines/bladerunner/light.h @@ -0,0 +1,104 @@ +/* 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. +* +*/ + +#ifndef BLADERUNNER_LIGHT_H +#define BLADERUNNER_LIGHT_H + +#include "bladerunner/matrix.h" +#include "bladerunner/color.h" + +#include "common/stream.h" + +namespace Common{ + class ReadStream; +} + +namespace BladeRunner { + class Lights; + + class Light + { + friend class Lights; + private: + char _name[20]; + int _framesCount; + int _animated; + int _animatedParameters; + Matrix4x3 _matrix; + Color _color; + float _field16; + float _field17; + float _field18; + float _field19; + float *_animationData; + float *_m11ptr; + float *_m12ptr; + float *_m13ptr; + float *_m14ptr; + float *_m21ptr; + float *_m22ptr; + float *_m23ptr; + float *_m24ptr; + float *_m31ptr; + float *_m32ptr; + float *_m33ptr; + float *_m34ptr; + float *_colorRPtr; + float *_colorGPtr; + float *_colorBPtr; + float *_field16ptr; + float *_field17ptr; + float *_field18ptr; + float *_field19ptr; + Light *_next; + public: + Light(); + ~Light(); + void read(Common::ReadStream *stream, int framesCount, int frame, int animated); + void readVqa(Common::ReadStream *stream); + + void setupFrame(int frame); + private: + static float attenuation(float min, float max, float distance); + }; + + class Light1 : public Light { + + }; + + class Light2 : public Light { + + }; + + class Light3 : public Light { + + }; + + class Light4 : public Light { + + }; + + class Light5 : public Light { + + }; +} +#endif diff --git a/engines/bladerunner/lights.cpp b/engines/bladerunner/lights.cpp new file mode 100644 index 0000000000..33ee3d1181 --- /dev/null +++ b/engines/bladerunner/lights.cpp @@ -0,0 +1,100 @@ +#include "bladerunner/lights.h" + +namespace BladeRunner { + Lights::Lights(BladeRunnerEngine *vm) + { + _vm = vm; + + _ambientLightColor.r = 1.0; + _ambientLightColor.g = 0.0; + _ambientLightColor.b = 0.0; + + _lights = NULL; + _frame = 0; + } + + Lights::~Lights() + { + reset(); + } + + void Lights::read(Common::ReadStream* stream, int framesCount) + { + _ambientLightColor.r = stream->readFloatLE(); + _ambientLightColor.g = stream->readFloatLE(); + _ambientLightColor.b = stream->readFloatLE(); + + _lightsCount = stream->readUint32LE(); + int i; + for (i = 0; i < _lightsCount; i++) + { + Light *light; + int type = stream->readUint32LE(); + switch (type) + { + case 1: + light = new Light1(); + break; + case 2: + light = new Light2(); + break; + case 3: + light = new Light3(); + break; + case 4: + light = new Light4(); + break; + case 5: + light = new Light5(); + break; + default: + light = new Light(); + } + + light->read(stream, framesCount, _frame, 0); + light->_next = _lights; + _lights = light; + } + } + + void Lights::readVqa(Common::ReadStream* stream) + { + reset(); + //int framesCount = stream->readUint32LE(); + //int count = stream->readUint32LE(); + + } + + void Lights::setupFrame(int frame) + { + Light *light; + + if (frame == _frame) + return; + + if (!_lights) + return; + + for (light = _lights; light; light = light->_next) + { + light->setupFrame(frame); + } + } + + void Lights::reset() + { + Light *light; + Light *nextLight; + + if (!_lights) + return; + + do + { + light = _lights; + nextLight = light->_next; + delete light; + _lights = nextLight; + } while (nextLight); + } +}
\ No newline at end of file diff --git a/engines/bladerunner/lights.h b/engines/bladerunner/lights.h new file mode 100644 index 0000000000..d6ff7f5261 --- /dev/null +++ b/engines/bladerunner/lights.h @@ -0,0 +1,64 @@ +/* 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. +* +*/ + +#ifndef BLADERUNNER_LIGHTS_H +#define BLADERUNNER_LIGHTS_H + +#include "bladerunner/bladerunner.h" +#include "bladerunner/color.h" +#include "bladerunner/light.h" + +#include "common/stream.h" + + +namespace BladeRunner { + + class Lights + { + BladeRunnerEngine *_vm; + + private: + Color _ambientLightColor; + + int _lightsCount; + Light *_lights; + + int _frame; + //char gap[28]; + + public: + Lights(BladeRunnerEngine *vm); + ~Lights(); + + void read(Common::ReadStream *stream, int framesCount); + void readVqa(Common::ReadStream *stream); + + void reset(); + + void setupFrame(int frame); + + private: + + }; + +} +#endif diff --git a/engines/bladerunner/movement_track.cpp b/engines/bladerunner/movement_track.cpp new file mode 100644 index 0000000000..fff4508dec --- /dev/null +++ b/engines/bladerunner/movement_track.cpp @@ -0,0 +1,124 @@ +/* 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/movement_track.h" + +namespace BladeRunner { + MovementTrack::MovementTrack() + { + reset(); + } + + MovementTrack::~MovementTrack() + { + reset(); + } + + void MovementTrack::reset() + { + _currentIndex = -1; + _lastIndex = -1; + _hasNext = 0; + _paused = 0; + for (int i = 0; i < sizeof(this->_entries); i++) + { + _entries[i].waypointId = -1; + _entries[i].delay = -1; + _entries[i].angle = -1; + _entries[i].running = 0; + } + } + + int MovementTrack::append(int waypointId, int delay, int running) + { + return append(waypointId, delay, -1, running); + } + + int MovementTrack::append(int waypointId, int delay, int angle, int running) + { + if (_lastIndex > sizeof(_entries)) + return 0; + _entries[_lastIndex].waypointId = waypointId; + _entries[_lastIndex].delay = delay; + _entries[_lastIndex].angle = angle; + _entries[_lastIndex].running = running; + + _lastIndex++; + _hasNext = 1; + _currentIndex = 0; + return 1; + } + + void MovementTrack::flush() + { + reset(); + } + + void MovementTrack::repeat() + { + _currentIndex = 0; + _hasNext = 1; + } + + int MovementTrack::pause() + { + _paused = 1; + return 1; + } + + int MovementTrack::unpause() + { + _paused = 0; + return 1; + } + + int MovementTrack::isPaused() + { + return _paused; + } + + int MovementTrack::hasNext() + { + return _hasNext; + } + + int MovementTrack::next(int *waypointId, int *delay, int *angle, int *running) + { + if (_currentIndex < _lastIndex && this->_hasNext) + { + *waypointId = _entries[_currentIndex].waypointId; + *delay = _entries[_currentIndex].delay; + *angle = _entries[_currentIndex].angle; + *running = _entries[_currentIndex++].running; + return 1; + } + else + { + *waypointId = -1; + *delay = -1; + *angle = -1; + *running = 0; + _hasNext = 0; + return 0; + } + } +}
\ No newline at end of file diff --git a/engines/bladerunner/movement_track.h b/engines/bladerunner/movement_track.h new file mode 100644 index 0000000000..491de8051a --- /dev/null +++ b/engines/bladerunner/movement_track.h @@ -0,0 +1,70 @@ +/* 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. +* +*/ + +#ifndef BLADERUNNER_MOVEMENT_TRACK_H +#define BLADERUNNER_MOVEMENT_TRACK_H + +#include "bladerunner/bladerunner.h" + + +namespace BladeRunner { + + class BladeRunnerEngine; + class BoundingBox; + + struct MovementTrackEntry + { + int waypointId; + int delay; + int angle; + int running; + }; + + class MovementTrack { + BladeRunnerEngine *_vm; + + private: + int _currentIndex; + int _lastIndex; + int _hasNext; + int _paused; + MovementTrackEntry _entries[100]; + void reset(); + + public: + MovementTrack(); + ~MovementTrack(); + int append(int waypointId, int delay, int running); + int append(int waypointId, int delay, int angle, int running); + void flush(); + void repeat(); + int pause(); + int unpause(); + int isPaused(); + int hasNext(); + int next(int *waypointId, int *delay, int *angle, int *running); + + //int saveGame(); + }; +} // End of namespace BladeRunner + +#endif diff --git a/engines/bladerunner/outtake.cpp b/engines/bladerunner/outtake.cpp index b81b212f52..3ffc964d03 100644 --- a/engines/bladerunner/outtake.cpp +++ b/engines/bladerunner/outtake.cpp @@ -43,7 +43,7 @@ void OuttakePlayer::play(const Common::String &name, bool noLocalization, int co else resName = name + "_E.VQA"; - VQAPlayer vqa_player(_vm); + VQAPlayer vqa_player(_vm, _vm->_view); vqa_player.open(resName); diff --git a/engines/bladerunner/scene.cpp b/engines/bladerunner/scene.cpp index 925c86afba..fc0aa8c20d 100644 --- a/engines/bladerunner/scene.cpp +++ b/engines/bladerunner/scene.cpp @@ -28,6 +28,8 @@ #include "bladerunner/chapters.h" #include "bladerunner/gameinfo.h" #include "bladerunner/script/script.h" +#include "bladerunner/slice_renderer.h" +#include "bladerunner/scene_objects.h" #include "common/str.h" #include "common/stream.h" @@ -38,7 +40,7 @@ bool Scene::open(int setId, int sceneId, bool isLoadingGame) { if (!isLoadingGame) { // flush ADQ } - + // reset mouse button status _setId = setId; _sceneId = sceneId; @@ -48,9 +50,11 @@ bool Scene::open(int setId, int sceneId, bool isLoadingGame) { // TODO: Set up overlays } else { // TODO: Clear regions + // reset aesc // TODO: Destroy all overlays _defaultLoop = 0; _frame = -1; + //_loopStartSpecial = -1; } Common::String vqaName; @@ -75,34 +79,50 @@ bool Scene::open(int setId, int sceneId, bool isLoadingGame) { if (!_set->open(setResourceName)) return false; - // TODO: Set view + _vm->_sliceRenderer->setView(_vm->_view); + if (isLoadingGame) { - if (sceneId >= 73 && sceneId <= 76) - _vm->_script->InitializeScene(); - return true; + // resume() + if (sceneId >= 73 && sceneId <= 76) { + _vm->_script->SceneLoaded(); + return true; + } } // TODO: set VQADecoder parameters // TODO: Set actor position from scene info + //advance frame 0 _vm->_playerActor->set_at_xyz(_actorStartPosition, _actorStartFacing); - // TODO: Set actor set - _vm->_script->SceneLoaded(); -#if 0 + _vm->_sceneObjects->reset(); + // Init click map int actorCount = _vm->_gameInfo->getActorCount(); for (int i = 0; i != actorCount; ++i) { Actor *actor = _vm->_actors[i]; if (actor->getSet() == setId) { - + _vm->_sceneObjects->addActor( + i, + actor->getBoundingBox(), + actor->getScreenRectangle(), + 1, + 0, + actor->isTargetable(), + actor->isRetired()); } } - // TODO: Update click map for set, items -#endif - + + _set->addAllObjectsToScene(_vm->_sceneObjects); + //add all items to scene + //calculate walking obstacles?? + + if (_playerWalkedIn) { + //_vm->_script->PlayerWalkedIn(); + } + return true; } @@ -111,7 +131,6 @@ int Scene::advanceFrame(Graphics::Surface &surface, uint16 *&zBuffer) { if (frame >= 0) { surface.copyFrom(*_vqaPlayer.getSurface()); memcpy(zBuffer, _vqaPlayer.getZBuffer(), 640*480*2); - _view = _vqaPlayer.getView(); } return frame; } diff --git a/engines/bladerunner/scene.h b/engines/bladerunner/scene.h index f0721b39e3..ee286cabb4 100644 --- a/engines/bladerunner/scene.h +++ b/engines/bladerunner/scene.h @@ -26,7 +26,7 @@ #include "bladerunner/bladerunner.h" #include "bladerunner/set.h" -#include "bladerunner/view.h" +//#include "bladerunner/view.h" #include "bladerunner/vqa_player.h" namespace BladeRunner { @@ -48,7 +48,6 @@ public: Vector3 _actorStartPosition; int _actorStartFacing; bool _playerWalkedIn; - View _view; public: Scene(BladeRunnerEngine *vm) @@ -56,7 +55,7 @@ public: _set(new Set(vm)), _setId(-1), _sceneId(-1), - _vqaPlayer(vm), + _vqaPlayer(vm, vm->_view), _defaultLoop(0), _nextSetId(-1), _nextSceneId(-1), diff --git a/engines/bladerunner/scene_objects.cpp b/engines/bladerunner/scene_objects.cpp new file mode 100644 index 0000000000..f54a9b7120 --- /dev/null +++ b/engines/bladerunner/scene_objects.cpp @@ -0,0 +1,188 @@ +#include "bladerunner/scene_objects.h" + +namespace BladeRunner { + + SceneObjects::SceneObjects(BladeRunnerEngine *vm, View *view) { + _vm = vm; + _view = view; + + _count = 0; + _sceneObjects = new SceneObject[SCENE_OBJECTS_COUNT]; + _sceneObjectsSortedByDistance = new int[SCENE_OBJECTS_COUNT]; + + int i; + for (i = 0; i < SCENE_OBJECTS_COUNT; i++) { + _sceneObjectsSortedByDistance[i] = -1; + } + } + + SceneObjects::~SceneObjects() { + _vm = nullptr; + _view = nullptr; + _count = 0; + + delete[] _sceneObjectsSortedByDistance; + delete[] _sceneObjects; + } + + + void SceneObjects::reset() { + int i; + for (i = 0; i < SCENE_OBJECTS_COUNT; i++) { + _sceneObjects[i]._present = 0; + } + } + + bool SceneObjects::addActor(int sceneObjectId, BoundingBox* boundingBox, Common::Rect* screenRectangle, uint8 isClickable, uint8 unknown1, uint8 isCombatTarget, uint8 isRetired) { + return addSceneObject(sceneObjectId, SceneObjectTypeActor, boundingBox, screenRectangle, isClickable, 0, 0, isCombatTarget, unknown1, isRetired); + } + + bool SceneObjects::addObject(int sceneObjectId, BoundingBox* boundingBox, uint8 isClickable, uint8 isObstacle, uint8 unknown1, uint8 isCombatTarget) { + Common::Rect rect(-1, -1, -1, -1); + return addSceneObject(sceneObjectId, SceneObjectTypeObject, boundingBox, &rect, isClickable, isObstacle, unknown1, isCombatTarget, 0, 0); + } + + bool SceneObjects::addItem(int sceneObjectId, BoundingBox* boundingBox, Common::Rect* screenRectangle, uint8 isCombatTarget, uint8 isObstacle) { + return addSceneObject(sceneObjectId, SceneObjectTypeItem, boundingBox, screenRectangle, isObstacle, 0, 0, isCombatTarget, 0, 0); + } + + + bool SceneObjects::remove(int sceneObjectId) + { + int i = findById(sceneObjectId); + if (i == -1 || !_sceneObjects[i]._present) { + return false; + } + int j; + for (j = 0; j < _count; j++) { + if (_sceneObjectsSortedByDistance[j] == i) { + break; + } + } + int k; + for (k = j; k < _count - 1; k++) { + _sceneObjectsSortedByDistance[k] = _sceneObjectsSortedByDistance[k + 1]; + } + + --_count; + return true; + } + + int SceneObjects::findByXYZ(int *isClickable, int *isObstacle, int *isCombatTarget, float x, float y, float z, int firstClickable, int firstObstacle, int firstCombatTarget) { + BoundingBox boundingBox; + *isClickable = 0; + *isObstacle = 0; + *isCombatTarget = 0; + + if (!_count) + return -1; + + int i; + for (i = 0; i < _count; i++) { + //assert(_sceneObjectsSortedByDistance[i] < _count); + SceneObject *sceneObject = &_sceneObjects[_sceneObjectsSortedByDistance[i]]; + if ((firstClickable && sceneObject->_isClickable) + || (firstObstacle && sceneObject->_isObstacle) + || (firstCombatTarget && sceneObject->_isCombatTarget)) { + break; + } + + boundingBox = sceneObject->_boundingBox; + + if (sceneObject->_sceneObjectType == SceneObjectTypeObject || sceneObject->_sceneObjectType == SceneObjectTypeItem) { + boundingBox.expand(-4.0, 0.0, -4.0, 4.0, 0.0, 4.0); + } + + if (boundingBox.isXYZInside(x, y, z)) { + *isClickable = sceneObject->_isClickable; + *isObstacle = sceneObject->_isObstacle; + *isCombatTarget = sceneObject->_isCombatTarget; + return sceneObject->_sceneObjectId; + } + } + + return -1; + } + + int SceneObjects::findById(int sceneObjectId) + { + int i; + for (i = 0; i < _count; i++) { + if (_sceneObjects[i]._present && _sceneObjects[i]._sceneObjectId == sceneObjectId) { + return i; + } + } + return -1; + } + + bool SceneObjects::addSceneObject(int sceneObjectId, SceneObjectType sceneObjectType, BoundingBox* boundingBox, Common::Rect* screenRectangle, uint8 isClickable, uint8 isObstacle, uint8 unknown1, uint8 isCombatTarget, uint unknown2, uint isRetired) { + int index = findEmpty(); + if (_count >= SCENE_OBJECTS_COUNT || index == -1) { + return false; + } + + _sceneObjects[index]._sceneObjectId = sceneObjectId; + _sceneObjects[index]._sceneObjectType = sceneObjectType; + _sceneObjects[index]._present = 1; + _sceneObjects[index]._boundingBox = *boundingBox; + _sceneObjects[index]._screenRectangle = *screenRectangle; + _sceneObjects[index]._isClickable = isClickable; + _sceneObjects[index]._isObstacle = isObstacle; + _sceneObjects[index]._unknown1 = unknown1; + _sceneObjects[index]._isCombatTarget = isCombatTarget; + _sceneObjects[index]._unknown2 = unknown2; + _sceneObjects[index]._isRetired = isRetired; + + float centerZ = (_sceneObjects[index]._boundingBox._vertices[0].z + _sceneObjects[index]._boundingBox._vertices[1].z) / 2.0; + + float distanceToCamera = fabs(_view->_cameraPosition.z - centerZ); + _sceneObjects[index]._distanceToCamera = distanceToCamera; + + // insert according to distance from camera + int i, j; + for (i = 0; i < _count; i++) { + if (distanceToCamera < _sceneObjects[_sceneObjectsSortedByDistance[i]]._distanceToCamera) { + break; + } + } + + for (j = _count - 1; j >= i; j--) { + _sceneObjectsSortedByDistance[j + 1] = _sceneObjectsSortedByDistance[j]; + } + + _sceneObjectsSortedByDistance[i] = index; + ++_count; + return true; + } + + int SceneObjects::findEmpty() + { + int i; + for (i = 0; i < SCENE_OBJECTS_COUNT; i++) + { + if (!_sceneObjects[i]._present) + return i; + } + return -1; + } + + + + SceneObject::SceneObject() + { + _sceneObjectId = -1; + _sceneObjectType = SceneObjectTypeUnknown; + _distanceToCamera = 0; + _present = 0; + _isClickable = 0; + _isObstacle = 0; + _unknown1 = 0; + _isCombatTarget = 0; + _unknown2 = 0; + _isRetired = 0; + } + + SceneObject::~SceneObject() + { + } +} diff --git a/engines/bladerunner/scene_objects.h b/engines/bladerunner/scene_objects.h new file mode 100644 index 0000000000..999d82179f --- /dev/null +++ b/engines/bladerunner/scene_objects.h @@ -0,0 +1,96 @@ +/* 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. +* +*/ + +#ifndef BLADERUNNER_SCENE_OBJECTS_H +#define BLADERUNNER_SCENE_OBJECTS_H + +#include "bladerunner/bladerunner.h" + +#include "bladerunner/boundingbox.h" +#include "bladerunner/view.h" + +#include "common/rect.h" + +namespace BladeRunner { + class BladeRunnerEngine; + class SceneObject; + + enum SceneObjectType + { + SceneObjectTypeUnknown = -1, + SceneObjectTypeActor = 0, + SceneObjectTypeObject = 1, + SceneObjectTypeItem = 2, + }; + +#define SCENE_OBJECTS_COUNT 115 +#define SCENE_OBJECTS_ACTORS_OFFSET 0 +#define SCENE_OBJECTS_ITEMS_OFFSET 74 +#define SCENE_OBJECTS_OBJECTS_OFFSET 198 + + + + class SceneObjects { + BladeRunnerEngine *_vm; + private: + View *_view; + int _count; + SceneObject *_sceneObjects; + int *_sceneObjectsSortedByDistance; + + public: + SceneObjects(BladeRunnerEngine *vm, View *view); + ~SceneObjects(); + void reset(); + bool addActor(int sceneObjectId, BoundingBox* boundingBox, Common::Rect* screenRectangle, uint8 isClickable, uint8 unknown1, uint8 isCombatTarget, uint8 isRetired); + bool addObject(int sceneObjectId, BoundingBox* boundingBox, uint8 isClickable, uint8 isObstacle, uint8 unknown1, uint8 isCombatTarget); + bool addItem(int sceneObjectId, BoundingBox* boundingBox, Common::Rect* screenRectangle, uint8 isCombatTarget, uint8 isObstacle); + bool remove(int sceneObjectId); + int findByXYZ(int* clickable, int* obstacle, int* targetable, float x, float y, float z, int firstClickable, int firstObstacle, int firstTargetable); + private: + int findById(int sceneObjectId); + bool addSceneObject(int sceneObjectId, SceneObjectType sceneObjectType, BoundingBox* boundingBox, Common::Rect* screenRectangle, uint8 isClickable, uint8 isObstacle, uint8 unknown1, uint8 isCombatTarget, uint unknown2, uint isRetired); + int findEmpty(); + }; + + class SceneObject + { + friend class SceneObjects; + private: + int _sceneObjectId; + SceneObjectType _sceneObjectType; + BoundingBox _boundingBox; + Common::Rect _screenRectangle; + float _distanceToCamera; + int _present; + int _isClickable; + int _isObstacle; + int _unknown1; + int _isCombatTarget; + int _unknown2; + int _isRetired; + public: + SceneObject(); + ~SceneObject(); + }; +} +#endif diff --git a/engines/bladerunner/set.cpp b/engines/bladerunner/set.cpp index c37b31a80e..a2e54107d2 100644 --- a/engines/bladerunner/set.cpp +++ b/engines/bladerunner/set.cpp @@ -23,12 +23,14 @@ #include "bladerunner/set.h" #include "bladerunner/bladerunner.h" +#include "bladerunner/slice_renderer.h" #include "common/debug.h" #include "common/ptr.h" #include "common/str.h" #include "common/stream.h" + namespace BladeRunner { #define kSet0 0x53657430 @@ -38,9 +40,12 @@ Set::Set(BladeRunnerEngine *vm) : _vm(vm) { _walkboxCount = 0; _objects = new Object[85]; _walkboxes = new Walkbox[95]; + _footstepSoundOverride = -1; + _effects = new SetEffects(vm); } Set::~Set() { + delete _effects; delete[] _objects; delete[] _walkboxes; } @@ -52,7 +57,7 @@ bool Set::open(const Common::String &name) { if (sig != kSet0) return false; - s->skip(4); // TODO: LITE length + int framesCount = s->readUint32LE(); _objectCount = s->readUint32LE(); assert(_objectCount <= 85); @@ -101,9 +106,24 @@ bool Set::open(const Common::String &name) { // debug("WALKBOX: %s", _walkboxes[i]._name); } - // TODO: Read LITE + _vm->_lights->reset(); + _vm->_lights->read(s.get(), framesCount); + _vm->_sliceRenderer->setLights(_vm->_lights); + _effects->reset(); + _effects->read(s.get(), framesCount); + _vm->_sliceRenderer->setSetEffects(_effects); return true; } + +void Set::addAllObjectsToScene(SceneObjects* sceneObjects) +{ + uint32 i; + for (i = 0; i < _objectCount; i++) + { + sceneObjects->addObject(i + SCENE_OBJECTS_OBJECTS_OFFSET, &_objects[i]._bbox, _objects[i]._isClickable, _objects[i]._isObstacle, _objects[i]._unknown1, _objects[i]._isCombatTarget); + } +} + } // End of namespace BladeRunner diff --git a/engines/bladerunner/set.h b/engines/bladerunner/set.h index e7358fdb2a..fba2d2a3ab 100644 --- a/engines/bladerunner/set.h +++ b/engines/bladerunner/set.h @@ -24,6 +24,10 @@ #define BLADERUNNER_SET_H #include "bladerunner/boundingbox.h" +#include "bladerunner/set_effects.h" +#include "bladerunner/lights.h" +#include "bladerunner/scene_objects.h" + #include "common/scummsys.h" #include "common/str.h" @@ -41,6 +45,7 @@ struct Object { uint8 _isClickable; uint8 _isHotMouse; uint8 _isCombatTarget; + uint8 _unknown1; }; struct Walkbox { @@ -53,19 +58,24 @@ struct Walkbox { class Set { BladeRunnerEngine *_vm; - uint32 _objectCount; - uint32 _walkboxCount; - Object *_objects; - Walkbox *_walkboxes; - int _walkboxStepSound[85]; - int _footstepSoundOverride; - float _unknown[10]; + uint32 _objectCount; + uint32 _walkboxCount; + Object *_objects; + Walkbox *_walkboxes; + int _walkboxStepSound[85]; + int _footstepSoundOverride; + SetEffects *_effects; +public: + public: Set(BladeRunnerEngine *vm); ~Set(); bool open(const Common::String &name); + void addAllObjectsToScene(SceneObjects *sceneObjects); + + }; } // End of namespace BladeRunner diff --git a/engines/bladerunner/set_effects.cpp b/engines/bladerunner/set_effects.cpp new file mode 100644 index 0000000000..f524820033 --- /dev/null +++ b/engines/bladerunner/set_effects.cpp @@ -0,0 +1,83 @@ +#include "bladerunner/set_effects.h" + +namespace BladeRunner +{ + SetEffects::SetEffects(BladeRunnerEngine* vm) + { + _vm = vm; + + _distanceColor.r = 1.0f; + _distanceColor.g = 1.0f; + _distanceColor.b = 1.0f; + _distanceCoeficient = 0.1f; + + _fadeColor.r = 0.0f; + _fadeColor.g = 0.0f; + _fadeColor.b = 0.0f; + _fadeDensity = 0.0f; + + _fogsCount = 0; + _fogs = NULL; + } + + SetEffects::~SetEffects() + { + reset(); + } + + void SetEffects::read(Common::ReadStream* stream, int framesCount) + { + _distanceCoeficient = stream->readFloatLE(); + _distanceColor.r = stream->readFloatLE(); + _distanceColor.g = stream->readFloatLE(); + _distanceColor.b = stream->readFloatLE(); + + _fogsCount = stream->readUint32LE(); + int i; + for (i = 0; i < _fogsCount; i++) + { + int type = stream->readUint32LE(); + Fog* fog = NULL; + switch(type) + { + case 0: + fog = new FogCone(); + break; + case 1: + fog = new FogSphere(); + break; + case 2: + fog = new FogBox(); + break; + } + if(!fog) + { + //TODO exception, unknown fog type + } + fog->read(stream, framesCount); + fog->_next = _fogs; + _fogs = fog; + } + } + + void SetEffects::reset() + { + Fog* fog, *nextFog; + + if (!_fogs) + return; + + do + { + fog = _fogs; + nextFog = fog->_next; + delete fog; + fog = nextFog; + } while (nextFog); + + } + + void SetEffects::setupFrame(int frame) + { + } +}
\ No newline at end of file diff --git a/engines/bladerunner/set_effects.h b/engines/bladerunner/set_effects.h new file mode 100644 index 0000000000..5165cfba94 --- /dev/null +++ b/engines/bladerunner/set_effects.h @@ -0,0 +1,62 @@ +/* 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. +* +*/ + +#ifndef BLADERUNNER_SET_EFFECTS_H +#define BLADERUNNER_SET_EFFECTS_H + +#include "bladerunner/bladerunner.h" +#include "bladerunner/color.h" +#include "bladerunner/fog.h" + +#include "common/stream.h" + + +namespace BladeRunner { + + class SetEffects + { + BladeRunnerEngine *_vm; + + private: + Color _distanceColor; + float _distanceCoeficient; + Color _fadeColor; + float _fadeDensity; + int _fogsCount; + Fog *_fogs; + + public: + SetEffects(BladeRunnerEngine *vm); + ~SetEffects(); + + void read(Common::ReadStream *stream, int framesCount); + + void reset(); + + void setupFrame(int frame); + + private: + + }; + +} +#endif diff --git a/engines/bladerunner/slice_renderer.cpp b/engines/bladerunner/slice_renderer.cpp index 4e2300ec7f..a1e8497dc9 100644 --- a/engines/bladerunner/slice_renderer.cpp +++ b/engines/bladerunner/slice_renderer.cpp @@ -24,6 +24,9 @@ #include "bladerunner/bladerunner.h" #include "bladerunner/slice_animations.h" +#include "bladerunner/lights.h" +#include "bladerunner/scene.h" +#include "bladerunner/set.h" #include "common/debug.h" #include "common/memstream.h" @@ -54,7 +57,7 @@ void dump(const char *str, Matrix4x3 m) { SliceRenderer::~SliceRenderer() { } -void SliceRenderer::setView(const View &view) { +void SliceRenderer::setView(View *view) { _view = view; } @@ -84,7 +87,7 @@ void SliceRenderer::setupFrame(int animation, int frame, Vector3 position, float Matrix3x2 SliceRenderer::calculateFacingRotationMatrix() { assert(_sliceFramePtr); - Matrix4x3 viewMatrix = _view._sliceViewMatrix; + Matrix4x3 viewMatrix = _view->_sliceViewMatrix; Vector3 viewPos = viewMatrix * _position; float dir = atan2f(viewPos.x, viewPos.z) + _facing; float s = sinf(dir); @@ -107,7 +110,7 @@ void SliceRenderer::calculateBoundingRect() { _minY = 0.0f; _maxY = 0.0f; - Matrix4x3 viewMatrix = _view._sliceViewMatrix; + Matrix4x3 viewMatrix = _view->_sliceViewMatrix; Vector3 frameBottom = Vector3(0.0f, 0.0f, _frameBottomZ); Vector3 frameTop = Vector3(0.0f, 0.0f, _frameBottomZ + _frameSliceCount * _frameSliceHeight); @@ -122,7 +125,7 @@ void SliceRenderer::calculateBoundingRect() { Matrix3x2 facingRotation = calculateFacingRotationMatrix(); - Matrix3x2 m4(_view._viewportDistance / bottom.z, 0.0f, 0.0f, + Matrix3x2 m4(_view->_viewportDistance / bottom.z, 0.0f, 0.0f, 0.0f, 25.5f, 0.0f); Matrix3x2 m2(_frameFront.x, 0.0f, _framePos.x, @@ -130,13 +133,13 @@ void SliceRenderer::calculateBoundingRect() { _field_109E = m4 * (facingRotation * m2); - Vector4 B6(_view._viewportHalfWidth + top.x / top.z * _view._viewportDistance, - _view._viewportHalfHeight + top.y / top.z * _view._viewportDistance, + Vector4 B6(_view->_viewportHalfWidth + top.x / top.z * _view->_viewportDistance, + _view->_viewportHalfHeight + top.y / top.z * _view->_viewportDistance, 1.0f / top.z, _frameSliceCount * (1.0f / top.z)); - Vector4 C2(_view._viewportHalfWidth + bottom.x / bottom.z * _view._viewportDistance, - _view._viewportHalfHeight + bottom.y / bottom.z * _view._viewportDistance, + Vector4 C2(_view->_viewportHalfWidth + bottom.x / bottom.z * _view->_viewportDistance, + _view->_viewportHalfHeight + bottom.y / bottom.z * _view->_viewportDistance, 1.0f / bottom.z, 0.0f); @@ -324,6 +327,9 @@ void setupLookupTable(int t[256], int inc) { void SliceRenderer::drawFrame(Graphics::Surface &surface, uint16 *zbuffer) { assert(_sliceFramePtr); + assert(_lights); + assert(_setEffects); + assert(_view); SliceLineIterator sliceLineIterator; sliceLineIterator.setup( @@ -333,6 +339,9 @@ void SliceRenderer::drawFrame(Graphics::Surface &surface, uint16 *zbuffer) { _field_109E // 3x2 matrix ); + _lights->setupFrame(_view->_frame); + _setEffects->setupFrame(_view->_frame); + setupLookupTable(_t1, sliceLineIterator._field_00[0][0]); setupLookupTable(_t2, sliceLineIterator._field_00[0][1]); setupLookupTable(_t4, sliceLineIterator._field_00[1][0]); @@ -407,4 +416,13 @@ void SliceRenderer::drawSlice(int slice, uint16 *frameLinePtr, uint16 *zbufLineP } } +void SliceRenderer::setLights(Lights* lights) +{ + _lights = lights; +} + +void SliceRenderer::setSetEffects(SetEffects* setEffects) +{ + _setEffects = setEffects; +} } // End of namespace BladeRunner diff --git a/engines/bladerunner/slice_renderer.h b/engines/bladerunner/slice_renderer.h index 79ebdd8951..c04560a35e 100644 --- a/engines/bladerunner/slice_renderer.h +++ b/engines/bladerunner/slice_renderer.h @@ -26,6 +26,8 @@ #include "bladerunner/vector.h" #include "bladerunner/view.h" #include "bladerunner/matrix.h" +#include "bladerunner/lights.h" +#include "bladerunner/set_effects.h" #include "graphics/surface.h" @@ -34,8 +36,9 @@ namespace Common { } namespace BladeRunner { + class SetEffects; -class BladeRunnerEngine; + class BladeRunnerEngine; class SliceRenderer { BladeRunnerEngine *_vm; @@ -46,7 +49,9 @@ class SliceRenderer { float _facing; float _scale; - View _view; + View *_view; + Lights *_lights; + SetEffects *_setEffects; void *_sliceFramePtr; @@ -75,6 +80,8 @@ class SliceRenderer { int _t5[256]; int _c6; + + Matrix3x2 calculateFacingRotationMatrix(); void drawSlice(int slice, uint16 *frameLinePtr, uint16 *zbufLinePtr); @@ -84,11 +91,16 @@ public: {} ~SliceRenderer(); - void setView(const View &view); + void setView(View *view); + void setLights(Lights *lights); + void setSetEffects(SetEffects *setEffects); + void setupFrame(int animation, int frame, Vector3 position, float facing, float scale = 1.0f); void calculateBoundingRect(); void drawFrame(Graphics::Surface &surface, uint16 *zbuffer); + + }; } // End of namespace BladeRunner diff --git a/engines/bladerunner/view.cpp b/engines/bladerunner/view.cpp index b3b6ad8ad2..029f829c0d 100644 --- a/engines/bladerunner/view.cpp +++ b/engines/bladerunner/view.cpp @@ -27,6 +27,11 @@ namespace BladeRunner { +View::View(BladeRunnerEngine* vm) +{ + _vm = vm; +} + bool View::read(Common::ReadStream *stream) { uint32 frame; frame = stream->readUint32LE(); diff --git a/engines/bladerunner/view.h b/engines/bladerunner/view.h index 511ea66d1b..3e3a0e86b1 100644 --- a/engines/bladerunner/view.h +++ b/engines/bladerunner/view.h @@ -23,6 +23,8 @@ #ifndef BLADERUNNER_VIEW_H #define BLADERUNNER_VIEW_H +#include "bladerunner/bladerunner.h" + #include "matrix.h" namespace Common { @@ -32,6 +34,7 @@ namespace Common { namespace BladeRunner { class View { + BladeRunnerEngine *_vm; public: float _fovX; Matrix4x3 _frameViewMatrix; @@ -44,8 +47,12 @@ public: float _viewportHalfHeight; float _viewportDistance; + View(BladeRunnerEngine *vm); + bool read(Common::ReadStream *stream); + + private: void setFovX(float fovX); void calculateSliceViewMatrix(); diff --git a/engines/bladerunner/vqa_decoder.cpp b/engines/bladerunner/vqa_decoder.cpp index d1e56a98d6..63378dc5e9 100644 --- a/engines/bladerunner/vqa_decoder.cpp +++ b/engines/bladerunner/vqa_decoder.cpp @@ -30,6 +30,7 @@ #include "common/array.h" #include "common/util.h" +#include "common/memstream.h" namespace BladeRunner { @@ -524,7 +525,12 @@ bool VQADecoder::readMFCI(Common::SeekableReadStream *s, uint32 size) { return true; } -VQADecoder::VQAVideoTrack::VQAVideoTrack(VQADecoder *vqaDecoder) { +void VQADecoder::decodeView(View* view) +{ + _videoTrack->decodeView(view); +} + + VQADecoder::VQAVideoTrack::VQAVideoTrack(VQADecoder *vqaDecoder) { VQADecoder::Header *header = &vqaDecoder->_header; _surface = nullptr; @@ -560,6 +566,8 @@ VQADecoder::VQAVideoTrack::VQAVideoTrack(VQADecoder *vqaDecoder) { _surface = new Graphics::Surface(); _surface->create(_width, _height, createRGB555()); + + _viewData = new uint8[56]; } VQADecoder::VQAVideoTrack::~VQAVideoTrack() { @@ -567,6 +575,7 @@ VQADecoder::VQAVideoTrack::~VQAVideoTrack() { delete[] _cbfz; delete[] _zbufChunk; delete[] _vpointer; + delete[] _viewData; if (_surface) _surface->free(); @@ -743,18 +752,29 @@ const uint16 *VQADecoder::VQAVideoTrack::decodeZBuffer() return _zbuffer; } -bool VQADecoder::VQAVideoTrack::readVIEW(Common::SeekableReadStream *s, uint32 size) + +void VQADecoder::VQAVideoTrack::decodeView(View* view) +{ + assert(_viewData); + assert(view); + + Common::MemoryReadStream s(_viewData, 56); + view->read(&s); +} + + bool VQADecoder::VQAVideoTrack::readVIEW(Common::SeekableReadStream *s, uint32 size) { if (size != 56) return false; - _view.read(s); + s->read(_viewData, 56); return true; } bool VQADecoder::VQAVideoTrack::readAESC(Common::SeekableReadStream *s, uint32 size) { + // some screen (2d not 3d) effects for transparency s->skip(roundup(size)); return true; } diff --git a/engines/bladerunner/vqa_decoder.h b/engines/bladerunner/vqa_decoder.h index 3f8c968b9e..c57372081d 100644 --- a/engines/bladerunner/vqa_decoder.h +++ b/engines/bladerunner/vqa_decoder.h @@ -52,8 +52,8 @@ public: const Graphics::Surface *decodeVideoFrame(); const uint16 *decodeZBuffer(); Audio::SeekableAudioStream *decodeAudioFrame(); - - const View &getView() { return _videoTrack->getView(); } + void decodeView(View *view); + //const View &getView() { return _videoTrack->getView(); } uint16 numFrames() const { return _header.numFrames; } uint8 frameRate() const { return _header.frameRate; } @@ -163,7 +163,7 @@ private: int getFrameCount() const; const Graphics::Surface *decodeVideoFrame(); const uint16 *decodeZBuffer(); - const View &getView() { return _view; } + void decodeView(View *view); bool readVQFR(Common::SeekableReadStream *s, uint32 size); bool readVPTR(Common::SeekableReadStream *s, uint32 size); @@ -207,7 +207,7 @@ private: int _curFrame; - View _view; + uint8 *_viewData; void VPTRWriteBlock(uint16 *frame, unsigned int dstBlock, unsigned int srcBlock, int count, bool alpha = false); bool decodeFrame(uint16 *frame); diff --git a/engines/bladerunner/vqa_player.cpp b/engines/bladerunner/vqa_player.cpp index 8146c1abf9..0a04d1b786 100644 --- a/engines/bladerunner/vqa_player.cpp +++ b/engines/bladerunner/vqa_player.cpp @@ -65,7 +65,7 @@ int VQAPlayer::update() { queueAudioFrame(_decoder.decodeAudioFrame()); _surface = _decoder.decodeVideoFrame(); _zBuffer = _decoder.decodeZBuffer(); - _view = _decoder.getView(); + _decoder.decodeView(_view); } _decodedFrame = calcNextFrame(_curFrame); @@ -89,7 +89,7 @@ int VQAPlayer::update() { if (_curFrame >= 0) { _surface = _decoder.decodeVideoFrame(); _zBuffer = _decoder.decodeZBuffer(); - _view = _decoder.getView(); + _decoder.decodeView(_view); } _decodedFrame = calcNextFrame(_curFrame); diff --git a/engines/bladerunner/vqa_player.h b/engines/bladerunner/vqa_player.h index 80ebf19d2f..98f1fcf51b 100644 --- a/engines/bladerunner/vqa_player.h +++ b/engines/bladerunner/vqa_player.h @@ -42,14 +42,14 @@ class VQAPlayer { const uint16 *_zBuffer; Audio::QueuingAudioStream *_audioStream; + View *_view; + int _curFrame; int _decodedFrame; int _curLoop; int _loopSpecial; int _loopDefault; - View _view; - uint32 _nextFrameTime; bool _hasAudio; bool _audioStarted; @@ -57,7 +57,7 @@ class VQAPlayer { public: - VQAPlayer(BladeRunnerEngine *vm) + VQAPlayer(BladeRunnerEngine *vm, View *view) : _vm(vm), _s(nullptr), _surface(nullptr), @@ -69,7 +69,8 @@ public: _loopDefault(-1), _nextFrameTime(0), _hasAudio(false), - _audioStarted(false) + _audioStarted(false), + _view(view) {} ~VQAPlayer() { @@ -82,7 +83,6 @@ public: int update(); const Graphics::Surface *getSurface() const; const uint16 *getZBuffer() const; - const View &getView() const { return _view; } void setLoopSpecial(int loop, bool wait); void setLoopDefault(int loop); |