aboutsummaryrefslogtreecommitdiff
path: root/engines/bladerunner
diff options
context:
space:
mode:
authorPeter Kohaut2016-09-10 18:16:17 +0200
committerEugene Sandulenko2016-09-29 22:33:40 +0200
commitb67bca20b5db7f3d6473341efd7fabfa6532f465 (patch)
tree6fbbd28dc707dac1c3cacde2e8622cceea6d1b0f /engines/bladerunner
parent2888d0b3460cdca2dd52f8d6aa94b429d46345ad (diff)
downloadscummvm-rg350-b67bca20b5db7f3d6473341efd7fabfa6532f465.tar.gz
scummvm-rg350-b67bca20b5db7f3d6473341efd7fabfa6532f465.tar.bz2
scummvm-rg350-b67bca20b5db7f3d6473341efd7fabfa6532f465.zip
BLADERUNNER: Pull in changes from madmoose
Diffstat (limited to 'engines/bladerunner')
-rw-r--r--engines/bladerunner/actor.cpp357
-rw-r--r--engines/bladerunner/actor.h48
-rw-r--r--engines/bladerunner/actor_clues.cpp299
-rw-r--r--engines/bladerunner/actor_clues.h127
-rw-r--r--engines/bladerunner/actor_combat.cpp6
-rw-r--r--engines/bladerunner/actor_combat.h115
-rw-r--r--engines/bladerunner/actor_walk.cpp224
-rw-r--r--engines/bladerunner/actor_walk.h77
-rw-r--r--engines/bladerunner/archive.cpp2
-rw-r--r--engines/bladerunner/audio_player.cpp19
-rw-r--r--engines/bladerunner/audio_speech.cpp8
-rw-r--r--engines/bladerunner/audio_speech.h2
-rw-r--r--engines/bladerunner/bladerunner.cpp127
-rw-r--r--engines/bladerunner/bladerunner.h20
-rw-r--r--engines/bladerunner/boundingbox.cpp15
-rw-r--r--engines/bladerunner/boundingbox.h9
-rw-r--r--engines/bladerunner/clues.cpp7
-rw-r--r--engines/bladerunner/clues.h6
-rw-r--r--engines/bladerunner/color.h54
-rw-r--r--engines/bladerunner/combat.cpp14
-rw-r--r--engines/bladerunner/combat.h9
-rw-r--r--engines/bladerunner/detection_tables.h2
-rw-r--r--engines/bladerunner/fog.cpp164
-rw-r--r--engines/bladerunner/fog.h180
-rw-r--r--engines/bladerunner/gameflags.cpp5
-rw-r--r--engines/bladerunner/image.cpp1
-rw-r--r--engines/bladerunner/image.h7
-rw-r--r--engines/bladerunner/item.cpp6
-rw-r--r--engines/bladerunner/item.h42
-rw-r--r--engines/bladerunner/items.cpp11
-rw-r--r--engines/bladerunner/items.h70
-rw-r--r--engines/bladerunner/light.cpp139
-rw-r--r--engines/bladerunner/light.h141
-rw-r--r--engines/bladerunner/lights.cpp161
-rw-r--r--engines/bladerunner/lights.h37
-rw-r--r--engines/bladerunner/matrix.cpp18
-rw-r--r--engines/bladerunner/matrix.h3
-rw-r--r--engines/bladerunner/module.mk18
-rw-r--r--engines/bladerunner/mouse.cpp88
-rw-r--r--engines/bladerunner/mouse.h10
-rw-r--r--engines/bladerunner/movement_track.cpp169
-rw-r--r--engines/bladerunner/movement_track.h66
-rw-r--r--engines/bladerunner/outtake.cpp2
-rw-r--r--engines/bladerunner/regions.cpp103
-rw-r--r--engines/bladerunner/regions.h54
-rw-r--r--engines/bladerunner/scene.cpp100
-rw-r--r--engines/bladerunner/scene.h36
-rw-r--r--engines/bladerunner/scene_objects.cpp154
-rw-r--r--engines/bladerunner/scene_objects.h110
-rw-r--r--engines/bladerunner/script/ai_00_mccoy.cpp174
-rw-r--r--engines/bladerunner/script/ai_00_mccoy.h45
-rw-r--r--engines/bladerunner/script/aiscript_officer_leroy.cpp87
-rw-r--r--engines/bladerunner/script/aiscript_officer_leroy.h41
-rw-r--r--engines/bladerunner/script/rc01.cpp195
-rw-r--r--engines/bladerunner/script/script.cpp192
-rw-r--r--engines/bladerunner/script/script.h75
-rw-r--r--engines/bladerunner/set.cpp122
-rw-r--r--engines/bladerunner/set.h26
-rw-r--r--engines/bladerunner/set_effects.cpp5
-rw-r--r--engines/bladerunner/set_effects.h43
-rw-r--r--engines/bladerunner/settings.cpp3
-rw-r--r--engines/bladerunner/settings.h2
-rw-r--r--engines/bladerunner/slice_animations.cpp32
-rw-r--r--engines/bladerunner/slice_animations.h15
-rw-r--r--engines/bladerunner/slice_renderer.cpp49
-rw-r--r--engines/bladerunner/slice_renderer.h11
-rw-r--r--engines/bladerunner/text_resource.cpp9
-rw-r--r--engines/bladerunner/view.cpp5
-rw-r--r--engines/bladerunner/view.h7
-rw-r--r--engines/bladerunner/vqa_decoder.cpp54
-rw-r--r--engines/bladerunner/vqa_decoder.h11
-rw-r--r--engines/bladerunner/vqa_player.cpp49
-rw-r--r--engines/bladerunner/vqa_player.h26
-rw-r--r--engines/bladerunner/waypoints.cpp4
-rw-r--r--engines/bladerunner/waypoints.h54
75 files changed, 3101 insertions, 1677 deletions
diff --git a/engines/bladerunner/actor.cpp b/engines/bladerunner/actor.cpp
index d16ee84f39..b4bdd68835 100644
--- a/engines/bladerunner/actor.cpp
+++ b/engines/bladerunner/actor.cpp
@@ -24,15 +24,22 @@
#include "bladerunner/bladerunner.h"
+#include "bladerunner/actor_clues.h"
+#include "bladerunner/actor_combat.h"
+#include "bladerunner/actor_walk.h"
+#include "bladerunner/audio_speech.h"
#include "bladerunner/boundingbox.h"
#include "bladerunner/gameinfo.h"
-#include "bladerunner/slice_renderer.h"
-#include "bladerunner/waypoints.h"
-#include "bladerunner/scene.h"
#include "bladerunner/items.h"
+#include "bladerunner/movement_track.h"
+#include "bladerunner/scene.h"
+#include "bladerunner/scene_objects.h"
#include "bladerunner/script/script.h"
#include "bladerunner/slice_animations.h"
-#include "bladerunner/audio_speech.h"
+#include "bladerunner/slice_renderer.h"
+#include "bladerunner/waypoints.h"
+
+#include "common/system.h"
namespace BladeRunner {
@@ -50,24 +57,22 @@ Actor::Actor(BladeRunnerEngine *vm, int actorId) {
}
Actor::~Actor() {
-
delete[] _friendlinessToOther;
delete _combatInfo;
delete _bbox;
delete _clues;
delete _movementTrack;
delete _walkInfo;
-
}
void Actor::setup(int actorId) {
_id = actorId;
_setId = -1;
- _position = Vector3(0.0, 0.0, 0.0);
- _facing = 512;
+ _position = Vector3(0.0, 0.0, 0.0);
+ _facing = 512;
_targetFacing = -1;
- _walkboxId = -1;
+ _walkboxId = -1;
_animationId = 0;
_animationFrame = 0;
@@ -77,7 +82,7 @@ void Actor::setup(int actorId) {
_isTargetable = false;
_isInvisible = false;
_isImmuneToObstacles = false;
-
+
_isRetired = false;
_width = 0;
@@ -87,7 +92,7 @@ void Actor::setup(int actorId) {
for (int i = 0; i != 7; ++i) {
_timersRemain[i] = 0;
- _timersBegan[i] = _vm->getTotalPlayTime();
+ _timersStart[i] = _vm->getTotalPlayTime();
}
_scale = 1.0;
@@ -104,6 +109,7 @@ void Actor::setup(int actorId) {
_timersRemain[4] = 60000;
_animationMode = -1;
_screenRectangle = Common::Rect(-1, -1, -1, -1);
+
_combatAnimationMode = 4;
_unknown1 = 7;
_unknown2 = 8;
@@ -119,17 +125,52 @@ void Actor::setup(int actorId) {
_actorSpeed = Vector3();
}
-void Actor::set_at_xyz(Vector3 position, int facing, bool halfOrSet, int moving, bool retired) {
- _position = position;
- setFacing(facing, halfOrSet);
-
- if(_vm->_scene->_setId == _setId) {
- _walkboxId = _vm->_scene->_set->findWalkbox(position.x, position.y);
- }else {
+void Actor::changeAnimationMode(int animationMode, bool force)
+{
+ if (force)
+ _animationMode = -1;
+
+ if (animationMode != _animationMode) {
+ _vm->_aiScripts->ChangeAnimationMode(_id, animationMode);
+ _animationMode = animationMode;
+ }
+}
+
+void Actor::setFPS(int fps)
+{
+ _fps = fps;
+
+ if (fps == 0)
+ {
+ _frame_ms = 0;
+ }
+ else if (fps == -1)
+ {
+ _frame_ms = -1000;
+ }
+ else if (fps == -2)
+ {
+ _fps = _vm->_sliceAnimations->getFPS(_animationId);
+ _frame_ms = 1000 / _fps;
+ }
+ else
+ {
+ _frame_ms = 1000 / fps;
+ }
+}
+
+void Actor::setAtXYZ(Vector3 pos, int facing, bool snapFacing, bool moving, bool retired)
+{
+ _position = pos;
+ setFacing(facing, snapFacing);
+
+ if (_vm->_scene->_setId == _setId) {
+ _walkboxId = _vm->_scene->_set->findWalkbox(_position.x, _position.y);
+ } else {
_walkboxId = -1;
}
- setBoundingBox(position, retired);
+ setBoundingBox(_position, retired);
_vm->_sceneObjects->remove(_id);
@@ -138,26 +179,152 @@ void Actor::set_at_xyz(Vector3 position, int facing, bool halfOrSet, int moving,
}
}
-
-void Actor::set_at_waypoint(int waypointId, int angle, int unknown, bool retired) {
+void Actor::setAtWaypoint(int waypointId, int angle, int moving, bool retired)
+{
Vector3 waypointPosition;
- _vm->_waypoints->getXyz(waypointId, &waypointPosition.x, &waypointPosition.y, &waypointPosition.z);
- set_at_xyz(waypointPosition, angle, true, unknown, retired);
+ _vm->_waypoints->getXYZ(waypointId, &waypointPosition.x, &waypointPosition.y, &waypointPosition.z);
+ setAtXYZ(waypointPosition, angle, true, moving, retired);
+}
+
+void Actor::loopWalkToXYZ(Vector3 destination)
+{
+ int unk1;
+ _walkInfo->setup(_id, false, _position, destination, 0, &unk1);
+
+ for (;;)
+ {
+ _vm->gameTick();
+ if (!_walkInfo->isWalking() && !_walkInfo->isRunning())
+ break;
+ if (!_vm->_gameIsRunning)
+ break;
+ }
+}
+
+float distance(float, float, float, float);
+float distance(Vector3 &v1, Vector3 &v2);
+
+void Actor::loopWalkToSceneObject(const char *objectName, int destinationOffset)
+{
+ int sceneObject = _vm->_scene->_set->findObject(objectName);
+ if (sceneObject < 0)
+ return;
+
+ BoundingBox bbox;
+ if (!_vm->_scene->_set->objectGetBoundingBox(sceneObject, &bbox))
+ return;
+
+ float x0, y0, z0, x1, y1, z1;
+ bbox.getXYZ(&x0, &y0, &z0, &x1, &y1, &z1);
+
+ // debug("[%f %f] -> [%f %f %f, %f %f %f]", _position.x, _position.z, x0, y0, z0, x1, y1, z1);
+
+ float closest_distance = distance(_position.x, _position.z, x0, z0);
+ float closest_x = x0;
+ float closest_z = z0;
+
+ float d = distance(_position.x, _position.z, x1, z0);
+ // debug("%f - %f %f %f %f", d, _position.x, _position.z, x1, z0);
+ if (d < closest_distance) {
+ closest_x = x1;
+ closest_z = z0;
+ closest_distance = d;
+ }
+
+ d = distance(_position.x, _position.z, x1, z1);
+ // debug("%f - %f %f %f %f", d, _position.x, _position.z, x1, z0);
+ if (d < closest_distance) {
+ closest_x = x1;
+ closest_z = z1;
+ closest_distance = d;
+ }
+
+ d = distance(_position.x, _position.z, x0, z1);
+ // debug("%f - %f %f %f %f", d, _position.x, _position.z, x1, z0);
+ if (d < closest_distance) {
+ closest_x = x0;
+ closest_z = z1;
+ closest_distance = d;
+ }
+
+ // debug("%f = %f %f %f %f", closest_distance, _position.x, _position.z, closest_x, closest_z);
+
+ Vector3 destination(closest_x, _position.y, closest_z);
+
+ // Vector3 properDestination(-124.2592, -0.3046913, 204.0923);
+ // debug("delta: %f\n", distance(destination, properDestination));
+
+ loopWalkToXYZ(destination);
+}
+
+bool Actor::tick(bool forceDraw)
+{
+ int remain = 0;
+ bool needsUpdate = false;
+ if (_fps > 0)
+ {
+ countdownTimerUpdate(5);
+ remain = countdownTimerGetRemainingTime(5);
+ needsUpdate = remain <= 0;
+ }
+ else if (forceDraw)
+ {
+ needsUpdate = true;
+ remain = 0;
+ }
+
+ if (needsUpdate)
+ {
+ int newAnimation = 0, newFrame = 0;
+ _vm->_aiScripts->UpdateAnimation(_id, &newAnimation, &newFrame);
+
+ if (_animationId != newAnimation) {
+ _animationId = newAnimation;
+ setFPS(-2);
+ }
+ _animationFrame = newFrame;
+
+ if (isWalking())
+ {
+ float stepDistance = 3.0;
+ if (stepDistance <= 0.0) {
+ stepDistance = 4.0;
+ }
+ if (_walkInfo->tick(_id, stepDistance, false)) {
+ _vm->_actors[_id]->changeAnimationMode(0);
+ }
+
+ Vector3 pos; int facing;
+ _walkInfo->getCurrentPosition(_id, &pos, &facing);
+
+ setAtXYZ(pos, facing);
+ }
+ }
+
+ draw();
+
+ if (needsUpdate)
+ {
+ int nextFrameTime = remain + _frame_ms;
+ if (nextFrameTime <= 0)
+ nextFrameTime = 1;
+ countdownTimerStart(5, nextFrameTime);
+ }
+
+ return false;
}
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_facing = M_PI - _facing * M_PI / 512.0;
// float draw_scale = _scale;
// TODO: Handle SHORTY mode
- _vm->_sliceRenderer->setupFrame(19, 1, draw_position, M_PI - draw_facing);
+ _vm->_sliceRenderer->setupFrame(_animationId, _animationFrame, draw_position, draw_facing);
_vm->_sliceRenderer->drawFrame(_vm->_surface2, _vm->_zBuffer2);
}
-
int Actor::getSetId() {
return _setId;
}
@@ -172,16 +339,16 @@ void Actor::setSetId(int setId) {
if(_setId > 0) {
for (i = 0; i < (int)_vm->_gameInfo->getActorCount(); i++) {
if (_vm->_actors[i]->_id != _id && _vm->_actors[i]->_setId == _setId) {
- //actorScript->OtherAgentExitedThisScene( i, _id);
+ // TODO: actorScript->OtherAgentExitedThisScene( i, _id);
}
}
}
_setId = setId;
- //actorScript->EnteredScene(_id, set);
+ // TODO: actorScript->EnteredScene(_id, set);
if (_setId > 0) {
for (i = 0; i < (int)_vm->_gameInfo->getActorCount(); i++) {
if (_vm->_actors[i]->_id != _id && _vm->_actors[i]->_setId == _setId) {
- //actorScript->OtherAgentEnteredThisScene(i, _id);
+ // TODO: actorScript->OtherAgentEnteredThisScene(i, _id);
}
}
}
@@ -221,41 +388,27 @@ void Actor::setFacing(int facing, bool halfOrSet) {
offset = -ccw / 2;
}
}
+
_facing = (_facing + offset) % 1024;
}
void Actor::setBoundingBox(Vector3 position, bool retired) {
if (retired) {
- _bbox->setXyz(position.x - (_retiredWidth / 2.0f), position.y, position.z - (_retiredWidth / 2.0f), position.x + (_retiredWidth / 2.0f), position.y + _retiredHeight, position.z + (_retiredWidth / 2.0f));
- } else {
- _bbox->setXyz(position.x - 12.0f, position.y + 6.0f, position.z - 12.0f, position.x + 12.0f, position.y + 72.0f, position.z + 12.0f);
- }
-}
-
-
-void Actor::changeAnimationMode(int animationMode, bool force) {
- if (force == 1) {
- _animationMode = -1;
- }
- if(animationMode != _animationMode) {
- //TODO: _vm->actorScript->ChangeAnimationMode(_id, animationMode);
- _animationMode = animationMode;
- }
-}
+ _bbox->setXYZ(position.x - (_retiredWidth / 2.0f),
+ position.y,
+ position.z - (_retiredWidth / 2.0f),
-void Actor::setFps(int fps) {
- _fps = fps;
- if (fps == 0) {
- _frame_ms = 0;
+ position.x + (_retiredWidth / 2.0f),
+ position.y + _retiredHeight,
+ position.z + (_retiredWidth / 2.0f));
} else {
- if(_fps == -1) {
- _frame_ms = -1000;
- } else if (_fps == -2) {
- _fps = _vm->_sliceAnimations->getFps(_animationId);
- _frame_ms = 1000 / _fps;
- } else {
- _frame_ms = 1000 / _fps;
- }
+ _bbox->setXYZ(position.x - 12.0f,
+ position.y + 6.0f,
+ position.z - 12.0f,
+
+ position.x + 12.0f,
+ position.y + 72.0f,
+ position.z + 12.0f);
}
}
@@ -268,9 +421,9 @@ void Actor::stopWalking(bool value) {
_vm->_playerActorIdle = true;
}
- if(isWalking()) {
+ if (isWalking()) {
_walkInfo->stop(_id, 1, _combatAnimationMode, 0);
- } else if(inCombat()) {
+ } else if (inCombat()) {
changeAnimationMode(_combatAnimationMode, 0);
} else {
changeAnimationMode(0, 0);
@@ -281,7 +434,7 @@ void Actor::faceActor(int otherActorId, bool animate) {
if (_setId != _vm->_scene->_setId) {
return;
}
-
+
Actor *otherActor = _vm->_actors[otherActorId];
if (_setId != otherActor->_setId) {
@@ -291,7 +444,7 @@ void Actor::faceActor(int otherActorId, bool animate) {
faceXYZ(otherActor->_position.x, otherActor->_position.y, otherActor->_position.z, animate);
}
-void Actor::faceObject(char *objectName, bool animate) {
+void Actor::faceObject(const char *objectName, bool animate) {
int objectId = _vm->_scene->findObject(objectName);
if (objectId == -1) {
return;
@@ -301,7 +454,7 @@ void Actor::faceObject(char *objectName, bool animate) {
_vm->_scene->objectGetBoundingBox(objectId, &boundingBox);
float x0, y0, z0, x1, y1, z1;
- boundingBox.getXyz(&x0, &y0, &z0, &x1, &y1, &z1);
+ boundingBox.getXYZ(&x0, &y0, &z0, &x1, &y1, &z1);
float x = (x1 + x0) / 2.0f;
float z = (z1 + z0) / 2.0f;
@@ -310,13 +463,13 @@ void Actor::faceObject(char *objectName, bool animate) {
void Actor::faceItem(int itemId, bool animate) {
float x, y, z;
- _vm->_items->getXyz(itemId, &x, &y, &z);
+ _vm->_items->getXYZ(itemId, &x, &y, &z);
faceXYZ(x, y, z, animate);
}
void Actor::faceWaypoint(int waypointId, bool animate) {
float x, y, z;
- _vm->_waypoints->getXyz(waypointId, &x, &y, &z);
+ _vm->_waypoints->getXYZ(waypointId, &x, &y, &z);
faceXYZ(x, y, z, animate);
}
@@ -413,15 +566,15 @@ bool Actor::getFlagDamageAnimIfMoving() {
return _damageAnimIfMoving;
}
-void Actor::retire(bool isRetired, int width, int height, int retiredByActorId) {
- _isRetired = isRetired;
+void Actor::retire(bool retired, int width, int height, int retiredByActorId) {
+ _isRetired = retired;
_retiredWidth = MAX(width, 0);
_retiredHeight = MAX(height, 0);
- if (_id == 0 && isRetired) {
+ if (_id == 0 && _isRetired) {
_vm->playerLosesControl();
_vm->_playerDead = true;
}
- if (isRetired) {
+ if (_isRetired) {
//TODO: _vm->actorScript->Retired(_id, retiredByActorId);
}
}
@@ -433,7 +586,7 @@ void Actor::setTargetable(bool targetable) {
void Actor::setHealth(int hp, int maxHp) {
_currentHP = hp;
_maxHP = maxHp;
- if(hp > 0) {
+ if (hp > 0) {
retire(0, 0, 0, -1);
}
}
@@ -519,11 +672,11 @@ void Actor::speechPlay(int sentenceId, bool voiceOver) {
sprintf(name, "%02d-%04d.AUD", _id, sentenceId); //TODO somewhere here should be also language code
int balance;
- if(voiceOver || _id == 99) {
+ if (voiceOver || _id == 99) {
balance = 0;
- }else {
- Vector3 pos = _vm->_view->_frameViewMatrix * _position;
- int screenX = 0, screenY = 0;
+ } else {
+ // Vector3 pos = _vm->_view->_frameViewMatrix * _position;
+ int screenX = 320; //, screenY = 0;
//TODO: transform to screen space using fov;
balance = 127 * (2 * screenX - 640) / 640;
balance = MIN(127, MAX(-127, balance));
@@ -560,7 +713,7 @@ void Actor::copyClues(int actorId) {
Actor *otherActor = _vm->_actors[actorId];
int i;
for (i = 0; i < (int)_vm->_gameInfo->getClueCount(); i++) {
- if(hasClue(i) && !_clues->isFlag4(i) && !otherActor->hasClue(i)) {
+ if (hasClue(i) && !_clues->isFlag4(i) && !otherActor->hasClue(i)) {
int fromActorId = _id;
if (_id == 99)
fromActorId = _clues->getFromActorId(i);
@@ -569,4 +722,58 @@ void Actor::copyClues(int actorId) {
}
}
+void Actor::countdownTimerStart(int timerId, int interval)
+{
+ assert(timerId >= 0 && timerId < 7);
+ _timersRemain[timerId] = interval;
+ _timersStart[timerId] = _vm->getTotalPlayTime();
+}
+
+void Actor::countdownTimerReset(int timerId)
+{
+ assert(timerId >= 0 && timerId < 7);
+ _timersRemain[timerId] = 0;
+}
+
+int Actor::countdownTimerGetRemainingTime(int timerId)
+{
+ assert(timerId >= 0 && timerId < 7);
+ return _timersRemain[timerId];
+}
+
+void Actor::countdownTimerUpdate(int timerId)
+{
+ if (_timersRemain[timerId] == 0)
+ return;
+
+ uint32 now = _vm->getTotalPlayTime();
+ int tickInterval = now - _timersStart[timerId];
+ _timersStart[timerId] = now;
+
+ // warning("tickInterval: %d", tickInterval);
+ _timersRemain[timerId] -= tickInterval;
+
+ if (_timersRemain[timerId] <= 0) {
+ switch (timerId) {
+ case 0:
+ case 1:
+ case 2:
+ // AI timers, call AI dll
+ break;
+ case 3:
+ // Movement track timer
+ break;
+ case 4:
+ // Something timer
+ break;
+ case 5:
+ // Actor animation frame timer
+ break;
+ case 6:
+ // Slow down actor run timer?
+ break;
+ }
+ }
+}
+
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/actor.h b/engines/bladerunner/actor.h
index 4d383f03b1..34d8a5abfb 100644
--- a/engines/bladerunner/actor.h
+++ b/engines/bladerunner/actor.h
@@ -23,24 +23,24 @@
#ifndef BLADERUNNER_ACTOR_H
#define BLADERUNNER_ACTOR_H
-#include "bladerunner/bladerunner.h"
-
#include "bladerunner/vector.h"
-#include "bladerunner/movement_track.h"
-#include "bladerunner/actor_clues.h"
-#include "bladerunner/actor_walk.h"
-#include "bladerunner/actor_combat.h"
#include "common/rect.h"
namespace BladeRunner {
+class ActorClues;
+class ActorCombat;
+class ActorWalk;
class BladeRunnerEngine;
class BoundingBox;
+class MovementTrack;
class Actor {
- BladeRunnerEngine *_vm;
friend class ScriptBase;
+
+ BladeRunnerEngine *_vm;
+
private:
BoundingBox *_bbox;
Common::Rect _screenRectangle;
@@ -58,7 +58,7 @@ private:
int _currentHP;
int _maxHP;
- ActorClues* _clues;
+ ActorClues *_clues;
int _id;
int _setId;
@@ -77,7 +77,7 @@ private:
bool _damageAnimIfMoving;
// Animation
- int _width;
+ int _width;
int _height;
int _animationMode;
int _combatAnimationMode;
@@ -89,15 +89,13 @@ private:
int _retiredWidth;
int _retiredHeight;
-
int _timersRemain[7];
- int _timersBegan[7];
+ int _timersStart[7];
float _scale;
int _unknown1;
int _unknown2;
- int _unknown3;
Vector3 _actorSpeed;
@@ -107,8 +105,8 @@ public:
void setup(int actorId);
- void set_at_xyz(Vector3 pos, int facing, bool halfOrSet, int unknown, bool retired);
- void set_at_waypoint(int waypointId, int angle, int unknown, bool retired);
+ void setAtXYZ(Vector3 pos, int facing, bool setFacing = true, bool moving = false, bool retired = false);
+ void setAtWaypoint(int waypointId, int angle, int unknown, bool retired);
float getX();
float getY();
@@ -117,8 +115,22 @@ public:
int getFacing();
int getAnimationMode();
+ Vector3 getPosition() { return _position; }
+
+ void changeAnimationMode(int animationMode, bool force = false);
+ void setFPS(int fps);
+
+ void loopWalkToXYZ(Vector3 destination);
+ void loopWalkToSceneObject(const char *objectName, int destinationOffset = 0);
+
+ bool tick(bool forceUpdate);
void draw();
+ void countdownTimerStart(int timerId, int interval);
+ void countdownTimerReset(int timerId);
+ int countdownTimerGetRemainingTime(int timerId);
+ void countdownTimerUpdate(int timerId);
+
int getSetId();
void setSetId(int setId);
BoundingBox* getBoundingBox() { return _bbox; }
@@ -131,12 +143,9 @@ public:
void setMoving(bool value) { _isMoving = value; }
bool isWalking();
void stopWalking(bool value);
-
- void changeAnimationMode(int animationMode, bool force);
- void setFps(int fps);
void faceActor(int otherActorId, bool animate);
- void faceObject(char *objectName, bool animate);
+ void faceObject(const char *objectName, bool animate);
void faceItem(int itemId, bool animate);
void faceWaypoint(int waypointId, bool animate);
void faceXYZ(float x, float y, float z, bool animate);
@@ -180,9 +189,8 @@ public:
bool hasClue(int clueId);
void copyClues(int actorId);
private:
- void setFacing(int facing, bool halfOrSet);
+ void setFacing(int facing, bool halfOrSet = true);
void setBoundingBox(Vector3 position, bool retired);
-
};
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/actor_clues.cpp b/engines/bladerunner/actor_clues.cpp
index c8bc04c328..2f02ddf0f1 100644
--- a/engines/bladerunner/actor_clues.cpp
+++ b/engines/bladerunner/actor_clues.cpp
@@ -1,181 +1,192 @@
#include "bladerunner/actor_clues.h"
-namespace BladeRunner
-{
+#include "bladerunner/clues.h"
- 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;
- }
+#include "common/debug.h"
- if (_maxCount > 0)
- _clues = new ActorClue[_maxCount];
- else
- _clues = NULL;
+namespace BladeRunner {
- if (_clues)
- removeAll();
- else
- _maxCount = NULL;
+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;
}
- ActorClues::~ActorClues()
- {
- if (_clues)
- delete[] _clues;
+ if (_maxCount > 0)
+ _clues = new ActorClue[_maxCount];
+ else
+ _clues = NULL;
+ if (_clues)
+ removeAll();
+ else
_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;
- }
+ActorClues::~ActorClues()
+{
+ if (_clues)
+ delete[] _clues;
- void ActorClues::lose(int clueId)
- {
- int clueIndex = findClueIndex(clueId);
- _clues[clueIndex]._flags = 0;
- }
+ _maxCount = 0;
+ _count = 0;
+}
- bool ActorClues::isAcquired(int clueId)
- {
- int clueIndex = findClueIndex(clueId);
- if (clueIndex == -1)
- return 0;
+void ActorClues::acquire(int clueId, char flag2, int fromActorId)
+{
+ int clueIndex = findClueIndex(clueId);
+ _clues[clueIndex]._flags |= 0x01;
+ _clues[_count]._flags = (_clues[_count]._flags & ~0x02) | ((flag2 << 1) & 0x02);
+ _clues[clueIndex]._fromActorId = fromActorId;
- return _clues[clueIndex]._flags & 0x01;
- }
+ debug("Actor acquired clue: \"%s\" from %d", _vm->_clues->getClueText(clueId), fromActorId);
+}
- int ActorClues::getFromActorId(int clueId)
- {
- int clueIndex = findClueIndex(clueId);
- if (clueIndex == -1)
- return -1;
+void ActorClues::lose(int clueId)
+{
+ int clueIndex = findClueIndex(clueId);
+ _clues[clueIndex]._flags = 0;
+}
- return _clues[clueIndex]._fromActorId;
- }
+bool ActorClues::isAcquired(int clueId)
+{
+ int clueIndex = findClueIndex(clueId);
+ if (clueIndex == -1)
+ return 0;
- bool ActorClues::isFlag2(int clueId)
- {
- int clueIndex = findClueIndex(clueId);
- if (clueIndex == -1)
- return 0;
+ return _clues[clueIndex]._flags & 0x01;
+}
- return (_clues[clueIndex]._flags & 0x02) >> 1;
- }
+int ActorClues::getFromActorId(int clueId)
+{
+ int clueIndex = findClueIndex(clueId);
+ if (clueIndex == -1)
+ return -1;
- bool ActorClues::isFlag3(int clueId)
- {
- int clueIndex = findClueIndex(clueId);
- if (clueIndex == -1)
- return 0;
+ return _clues[clueIndex]._fromActorId;
+}
- return (_clues[clueIndex]._flags & 0x04) >> 2;
- }
+bool ActorClues::isFlag2(int clueId)
+{
+ int clueIndex = findClueIndex(clueId);
+ if (clueIndex == -1)
+ return 0;
- bool ActorClues::isFlag4(int clueId)
- {
- int clueIndex = findClueIndex(clueId);
- if (clueIndex == -1)
- return 0;
+ return (_clues[clueIndex]._flags & 0x02) >> 1;
+}
- return (_clues[clueIndex]._flags & 0x08) >> 3;
- }
+bool ActorClues::isFlag3(int clueId)
+{
+ int clueIndex = findClueIndex(clueId);
+ if (clueIndex == -1)
+ return 0;
- int ActorClues::getField1(int clueId)
- {
- if (!_count)
- return 0;
+ return (_clues[clueIndex]._flags & 0x04) >> 2;
+}
- int clueIndex = findClueIndex(clueId);
- if (clueIndex == -1)
- return 0;
+bool ActorClues::isFlag4(int clueId)
+{
+ int clueIndex = findClueIndex(clueId);
+ if (clueIndex == -1)
+ return 0;
- return _clues[clueIndex]._field1;
- }
+ return (_clues[clueIndex]._flags & 0x08) >> 3;
+}
- int ActorClues::getCount()
- {
- return _count;
- }
+int ActorClues::getField1(int clueId)
+{
+ if (!_count)
+ return 0;
- void ActorClues::removeAll()
- {
- _count = 0;
- for (int i = 0; i < _maxCount; ++i) {
- remove(i);
- }
+ 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;
- }
+int ActorClues::findClueIndex(int clueId)
+{
+ for (int i = 0; i < _count; i++) {
+ if (clueId == _clues[i]._clueId) {
+ return i;
}
- return -1;
}
+ return -1;
+}
- void ActorClues::add(int actorId, int clueId, int unknown, bool acquired, bool unknownFlag, int fromActorId)
- {
- _clues[_count]._clueId = clueId;
- _clues[_count]._field1 = unknown;
+void ActorClues::add(int actorId, int clueId, int unknown, bool acquired, bool unknownFlag, int fromActorId)
+{
+ assert(_count < _maxCount);
- _clues[_count]._flags = 0;
- _clues[_count]._flags = _clues[_count]._flags & 0xFE | (acquired & 0x01);
- _clues[_count]._flags = _clues[_count]._flags & 0xFD | ((unknownFlag << 1) & 0x02);
+ debug("Actor %d added clue: \"%s\" from %d", actorId, _vm->_clues->getClueText(clueId), fromActorId);
- _clues[_count]._fromActorId = fromActorId;
- ++_count;
- }
+ _clues[_count]._clueId = clueId;
+ _clues[_count]._field1 = unknown;
- 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;
- }
+ _clues[_count]._flags = 0;
+ _clues[_count]._flags = (_clues[_count]._flags & ~0x01) | (acquired & 0x01);
+ _clues[_count]._flags = (_clues[_count]._flags & ~0x02) | ((unknownFlag << 1) & 0x02);
- bool ActorClues::exists(int clueId)
- {
- return findClueIndex(clueId) != -1;
- }
+ _clues[_count]._fromActorId = fromActorId;
+ ++_count;
+}
+void ActorClues::remove(int index)
+{
+ if (_vm->_clues)
+ debug("Actor removed clue: \"%s\"", _vm->_clues->getClueText(_clues[index]._clueId));
+
+ _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;
+}
+
+bool ActorClues::exists(int clueId)
+{
+ return findClueIndex(clueId) != -1;
+}
-} \ No newline at end of file
+} // End of namespace BladeRunner
diff --git a/engines/bladerunner/actor_clues.h b/engines/bladerunner/actor_clues.h
index 0f08254a60..06ac815c34 100644
--- a/engines/bladerunner/actor_clues.h
+++ b/engines/bladerunner/actor_clues.h
@@ -1,24 +1,24 @@
/* 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.
-*
-*/
+ *
+ * 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
@@ -29,55 +29,56 @@
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;
- };
+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;
+class ActorClues
+{
+ BladeRunnerEngine *_vm;
- private:
- int _count;
- int _maxCount;
- ActorClue *_clues;
+private:
+ int _count;
+ int _maxCount;
+ ActorClue *_clues;
- public:
- ActorClues(BladeRunnerEngine *_vm, int cluesType);
- ~ActorClues();
+public:
+ ActorClues(BladeRunnerEngine *_vm, int cluesType);
+ ~ActorClues();
- void add(int actorId, int clueId, int unknown, bool acquired, bool unknownFlag, int fromActorId);
- void acquire(int clueId, char flag2, int fromActorId);
- void lose(int clueId);
- bool isAcquired(int clueId);
- int getFromActorId(int clueId);
- bool isFlag2(int clueId);
- bool isFlag3(int clueId);
- bool isFlag4(int clueId);
- int getField1(int clueId);
+ void add(int actorId, int clueId, int unknown, bool acquired, bool unknownFlag, int fromActorId);
+ void acquire(int clueId, char flag2, int fromActorId);
+ void lose(int clueId);
+ bool isAcquired(int clueId);
+ int getFromActorId(int clueId);
+ bool isFlag2(int clueId);
+ bool isFlag3(int clueId);
+ bool isFlag4(int clueId);
+ int getField1(int clueId);
- int getCount();
+ int getCount();
- void removeAll();
+ void removeAll();
- //savegame
- //loadgame
- private:
- bool exists(int clueId);
- int findClueIndex(int clueId);
- void remove(int clueIndex);
-
- };
-}
+ //savegame
+ //loadgame
+
+private:
+ bool exists(int clueId);
+ int findClueIndex(int clueId);
+ void remove(int clueIndex);
+};
+
+} // End of namespace BladeRunner
#endif
diff --git a/engines/bladerunner/actor_combat.cpp b/engines/bladerunner/actor_combat.cpp
index f595b010ee..aac908661d 100644
--- a/engines/bladerunner/actor_combat.cpp
+++ b/engines/bladerunner/actor_combat.cpp
@@ -9,18 +9,16 @@ ActorCombat::ActorCombat(BladeRunnerEngine* vm) {
ActorCombat::~ActorCombat() {
}
-
void ActorCombat::hitAttempt() {
}
-
void ActorCombat::combatOn(int actorId, int a3, int a4, int otherActorId, int a6, int a7, int a8, int a9, int ammoDamage, int a11, int a12) {
}
void ActorCombat::combatOff() {
}
-
void ActorCombat::setup() {
}
-} \ No newline at end of file
+
+} // End of namespace BladeRunner
diff --git a/engines/bladerunner/actor_combat.h b/engines/bladerunner/actor_combat.h
index 0f6ccc9102..37fc57742a 100644
--- a/engines/bladerunner/actor_combat.h
+++ b/engines/bladerunner/actor_combat.h
@@ -1,24 +1,24 @@
/* 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.
-*
-*/
+ *
+ * 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_COMBAT_H
#define BLADERUNNER_ACTOR_COMBAT_H
@@ -28,45 +28,46 @@
#include "bladerunner/vector.h"
namespace BladeRunner {
-
- class ActorCombat
- {
- BladeRunnerEngine *_vm;
- private:
- int _actorId;
- int _combatOn;
- int _field2;
- int _field3;
- int _otherActorId;
- int _field5;
- int _field6;
- int _field7;
- int _field8;
- int _field9;
- int _field10;
- int _field11;
- int _field12;
- int _actorHp;
- int _field14;
- int _field15;
- Vector3 actorPosition;
- Vector3 otherActorPosition;
- int _availableCoversCount;
- int _availableFleeWaypointsCount;
- int _field24;
- public:
- ActorCombat(BladeRunnerEngine *vm);
- ~ActorCombat();
-
- void setup();
+class ActorCombat
+{
+ BladeRunnerEngine *_vm;
- void hitAttempt();
-
- void combatOn(int actorId, int a3, int a4, int otherActorId, int a6, int a7, int a8, int a9, int a10, int a11, int a12);
- void combatOff();
+private:
+ int _actorId;
+ int _combatOn;
+ int _field2;
+ int _field3;
+ int _otherActorId;
+ int _field5;
+ int _field6;
+ int _field7;
+ int _field8;
+ int _field9;
+ int _field10;
+ int _field11;
+ int _field12;
+ int _actorHp;
+ int _field14;
+ int _field15;
+ Vector3 actorPosition;
+ Vector3 otherActorPosition;
+ int _availableCoversCount;
+ int _availableFleeWaypointsCount;
+ int _field24;
- };
-}
+public:
+ ActorCombat(BladeRunnerEngine *vm);
+ ~ActorCombat();
+
+ void setup();
+
+ void hitAttempt();
+
+ void combatOn(int actorId, int a3, int a4, int otherActorId, int a6, int a7, int a8, int a9, int a10, int a11, int a12);
+ void combatOff();
+};
+
+} // End of namespace BladeRunner
#endif
diff --git a/engines/bladerunner/actor_walk.cpp b/engines/bladerunner/actor_walk.cpp
index e814180502..5b237362c9 100644
--- a/engines/bladerunner/actor_walk.cpp
+++ b/engines/bladerunner/actor_walk.cpp
@@ -1,40 +1,234 @@
+/* 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/actor_walk.h"
+
+#include "bladerunner/bladerunner.h"
+
#include "bladerunner/actor.h"
#include "bladerunner/scene_objects.h"
-namespace BladeRunner
-{
+namespace BladeRunner {
- ActorWalk::ActorWalk(BladeRunnerEngine *vm) {
+static int angle_1024(float x1, float z1, float x2, float z2);
+static int angle_1024(Vector3 &v1, Vector3 &v2);
+float distance(float x1, float x2, float z1, float z2);
+float distance(Vector3 &v1, Vector3 &v2);
+
+ActorWalk::ActorWalk(BladeRunnerEngine *vm) {
_vm = vm;
+
+ _walking = 0;
+ _running = 0;
+ _facing = -1;
+ _status = 0;
}
ActorWalk::~ActorWalk() {
}
-bool ActorWalk::isWalking() {
- return _walking;
+int ActorWalk::setup(int actorId, int run, Vector3 from, Vector3 to, int unk1, int *unk2)
+{
+ Vector3 next;
+
+ *unk2 = 0;
+ int r = nextOnPath(actorId, from, to, &next);
+
+ if (r == 0) {
+ if (actorId != 0)
+ {
+ _current = from;
+ _destination = to;
+ stop(actorId, false);
+ }
+ else
+ {
+ stop(actorId, true);
+ }
+ return 0;
+ }
+ if (r == -1)
+ {
+ stop(actorId, true);
+ *unk2 = 1;
+ return 0;
+ }
+
+ // TODO: Init array
+ // TODO: Update screen index
+ // Set actor field e8
+
+ if (_running)
+ {
+ run = true;
+ }
+
+ int animationMode;
+ if (_vm->_actors[actorId]->inCombat())
+ {
+ animationMode = run ? 8 : 7;
+ }
+ else
+ {
+ animationMode = run ? 2 : 1;
+ }
+
+ _vm->_actors[actorId]->changeAnimationMode(animationMode);
+
+ _destination = to;
+ _current = from;
+ _next = next;
+
+ if (next.x != _current.x || next.z != _current.z)
+ {
+ _facing = angle_1024(_current, next);
+ _walking = true;
+ _running = run;
+ _status = 2;
+
+ return 1;
+ }
+
+ stop(actorId, true);
+ return 0;
+}
+
+bool ActorWalk::tick(int actorId, float stepDistance, bool flag)
+{
+ if (_status == 5)
+ {
+ if (flag)
+ {
+ stop(actorId, true);
+ return true;
+ }
+
+ if (actorId != 0 && _vm->_rnd.getRandomNumberRng(1, 15) != 1)
+ {
+ return false;
+ }
+ _status = 3;
+ }
+ // TODO: Handle collisions?
+
+ if (stepDistance > distance(_current, _destination))
+ {
+ stop(actorId, true);
+ _current = _destination;
+ // TODO: Update y from walkbox
+ return true;
+ }
+
+ float angle_rad = _facing / 512.0 * M_PI;
+
+ _current = Vector3(
+ _current.x + stepDistance * sinf(angle_rad),
+ _current.y, // TODO: Update from walkbox
+ _current.z - stepDistance * cosf(angle_rad)
+ );
+
+ return false;
+}
+
+void ActorWalk::getCurrentPosition(int actorId, Vector3 *pos, int *facing)
+{
+ *pos = _current;
+ *facing = _facing;
+}
+
+void ActorWalk::setRunning()
+{
+ _running = true;
+ // TODO: Set animation mode
}
void ActorWalk::stop(int actorId, bool unknown, int animationMode, int notused) {
- _vm->_sceneObjects->setMoving(actorId, 0);
+ _vm->_sceneObjects->setMoving(actorId, 0);
_vm->_actors[actorId]->setMoving(0);
- if(_vm->_actors[actorId]->inCombat()) {
+ if (_vm->_actors[actorId]->inCombat()) {
_vm->_actors[actorId]->changeAnimationMode(animationMode, 0);
} else {
_vm->_actors[actorId]->changeAnimationMode(notused, 0);
}
-
- if(unknown) {
- _walking = 0;
- _running = 0;
+
+ if (unknown) {
+ _walking = false;
+ _running = false;
_status = 0;
- }else {
- _walking = 1;
- _running = 0;
+ } else {
+ _walking = true;
+ _running = false;
_status = 5;
}
}
-} \ No newline at end of file
+int ActorWalk::nextOnPath(int actorId, Vector3 from, Vector3 to, Vector3 *next)
+{
+ if (distance(from, to) < 6.0)
+ {
+ return -1;
+ }
+
+ // if (_vm->_actors[actorId]->getImmunityToObstacles()) {
+ *next = to;
+ return 1;
+ // }
+
+ error("TODO!");
+}
+
+static
+int angle_1024(float x1, float z1, float x2, float z2)
+{
+ float angle_rad = atan2(x2 - x1, z1 - z2);
+ int a = int(512.0 * angle_rad / M_PI);
+ return (a + 1024) % 1024;
+}
+
+static
+int angle_1024(Vector3 &v1, Vector3 &v2)
+{
+ return angle_1024(v1.x, v1.z, v2.x, v2.z);
+}
+
+float distance(float x1, float z1, float x2, float z2)
+{
+ float dx = x1 - x2;
+ float dz = z1 - z2;
+ float d = sqrt(dx*dx + dz*dz);
+
+ float int_part = (int)d;
+ float frac_part = d - int_part;
+
+ if (frac_part < 0.001)
+ frac_part = 0.0;
+
+ return int_part + frac_part;
+}
+
+float distance(Vector3 &v1, Vector3 &v2)
+{
+ return distance(v1.x, v1.z, v2.x, v2.z);
+}
+
+} // End of namespace BladeRunner
diff --git a/engines/bladerunner/actor_walk.h b/engines/bladerunner/actor_walk.h
index c38218937f..8b343bb0f7 100644
--- a/engines/bladerunner/actor_walk.h
+++ b/engines/bladerunner/actor_walk.h
@@ -23,40 +23,53 @@
#ifndef BLADERUNNER_ACTOR_WALK_H
#define BLADERUNNER_ACTOR_WALK_H
-#include "bladerunner/bladerunner.h"
#include "bladerunner/vector.h"
-namespace BladeRunner
+namespace BladeRunner {
+
+class BladeRunnerEngine;
+
+struct ActorWalkEntry
+{
+ int _actorId;
+ int _present;
+};
+
+class ActorWalk
{
- struct ActorWalkEntry
- {
- int _actorId;
- int _present;
- };
-
- class ActorWalk
- {
- BladeRunnerEngine *_vm;
- private:
- int _walking;
- int _running;
- Vector3 _wanted;
- Vector3 _unknown;
- Vector3 _start;
- Vector3 _end;
- int facing;
- ActorWalkEntry _actors[20];
- int _actorsCount;
- int _field15;
- int _status;
- public:
- ActorWalk(BladeRunnerEngine *vm);
- ~ActorWalk();
-
- bool isWalking();
- void stop(int actorId, bool unknown, int animationMode, int notused);
-
- };
-}
+ BladeRunnerEngine *_vm;
+
+private:
+ int _walking;
+ int _running;
+ Vector3 _destination;
+ Vector3 _unknown;
+ Vector3 _current;
+ Vector3 _next;
+ int _facing;
+ ActorWalkEntry _actors[20];
+ int _actorsCount;
+ int _field15;
+ int _status;
+
+public:
+ ActorWalk(BladeRunnerEngine *vm);
+ ~ActorWalk();
+
+ int setup(int actorId, int run, Vector3 from, Vector3 to, int unk1, int *unk2);
+ void getCurrentPosition(int actorId, Vector3 *pos, int *facing);
+ bool tick(int actorId, float stepDistance, bool flag);
+
+ bool isWalking() { return _walking; }
+ bool isRunning() { return _running; }
+ void setRunning();
+
+ void stop(int actorId, bool unknown, int animationMode = 4, int notused = 0);
+ // void setWalkingMode(int actorId, int active, int unk2 = 4, int unk3 = 0);
+
+ int nextOnPath(int actorId, Vector3 from, Vector3 to, Vector3 *next);
+};
+
+} // End of namespace BladeRunner
#endif
diff --git a/engines/bladerunner/archive.cpp b/engines/bladerunner/archive.cpp
index 051fcd80c3..464ca15929 100644
--- a/engines/bladerunner/archive.cpp
+++ b/engines/bladerunner/archive.cpp
@@ -65,7 +65,7 @@ bool MIXArchive::open(const Common::String &filename) {
return false;
}
- debug("MIXArchive::open: Opened archive %s", filename.c_str());
+ // debug("MIXArchive::open: Opened archive %s", filename.c_str());
return true;
}
diff --git a/engines/bladerunner/audio_player.cpp b/engines/bladerunner/audio_player.cpp
index b8df01cd85..851b0bc6f7 100644
--- a/engines/bladerunner/audio_player.cpp
+++ b/engines/bladerunner/audio_player.cpp
@@ -165,21 +165,20 @@ 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 = -1;
Track *track = NULL;
- int lowestPriority = 100;
+ int lowestPriority;
Track *lowestPriorityTrack = NULL;
for (int i = 0; i != 6; ++i) {
- track = &_tracks[i];
- if (!isTrackActive(track)) {
- trackId = 1;
+ Track *ti = &_tracks[i];
+ if (!isTrackActive(ti)) {
+ track = ti;
break;
}
- if (track->priority < lowestPriority) {
- lowestPriority = track->priority;
- lowestPriorityTrack = track;
+ if (lowestPriorityTrack == NULL || ti->priority < lowestPriority) {
+ lowestPriority = ti->priority;
+ lowestPriorityTrack = ti;
}
}
@@ -222,7 +221,7 @@ int AudioPlayer::playAud(const Common::String &name, int volume, int panFrom, in
Audio::SoundHandle soundHandle;
- debug("PlayStream: %s", name.c_str());
+ // debug("PlayStream: %s", name.c_str());
int balance = panFrom;
@@ -240,7 +239,7 @@ int AudioPlayer::playAud(const Common::String &name, int volume, int panFrom, in
track->hash = hash;
track->volume = volume;
- return trackId;
+ return track - &_tracks[0];
}
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/audio_speech.cpp b/engines/bladerunner/audio_speech.cpp
index 6fa9c9406a..7e7e4f0b78 100644
--- a/engines/bladerunner/audio_speech.cpp
+++ b/engines/bladerunner/audio_speech.cpp
@@ -44,16 +44,16 @@ AudioSpeech::~AudioSpeech() {
}
bool AudioSpeech::playSpeech(const char *name, int balance) {
-
+ // debug("AudioSpeech::playSpeech(\"%s\")", name);
Common::ScopedPtr<Common::SeekableReadStream> r(_vm->getResourceStream(name));
if (!r) {
- debug("AudioSpeech::playSpeech: AUD resource \"%s\" not found", name);
+ warning("AudioSpeech::playSpeech: AUD resource \"%s\" not found", name);
return false;
}
if (r->size() > BUFFER_SIZE) {
- debug("AudioSpeech::playSpeech: AUD larger than buffer size (%d > %d)", r->size(), BUFFER_SIZE);
+ warning("AudioSpeech::playSpeech: AUD larger than buffer size (%d > %d)", r->size(), BUFFER_SIZE);
return false;
}
@@ -63,7 +63,7 @@ bool AudioSpeech::playSpeech(const char *name, int balance) {
r->read(_data, r->size());
if (r->err()) {
- debug("AudioSpeech::playSpeech: Error reading resource \"%s\"", name);
+ warning("AudioSpeech::playSpeech: Error reading resource \"%s\"", name);
return false;
}
diff --git a/engines/bladerunner/audio_speech.h b/engines/bladerunner/audio_speech.h
index e122422724..ae7065865b 100644
--- a/engines/bladerunner/audio_speech.h
+++ b/engines/bladerunner/audio_speech.h
@@ -41,7 +41,7 @@ public:
AudioSpeech(BladeRunnerEngine *vm);
~AudioSpeech();
- bool playSpeech(const char *name, int balance = 50);
+ bool playSpeech(const char *name, int balance = 0);
void stopSpeech();
bool isPlaying();
void setVolume(int volume) { _volume = volume; }
diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp
index 0f5f320382..bd38fe7e75 100644
--- a/engines/bladerunner/bladerunner.cpp
+++ b/engines/bladerunner/bladerunner.cpp
@@ -29,9 +29,12 @@
#include "bladerunner/audio_speech.h"
#include "bladerunner/chapters.h"
#include "bladerunner/clues.h"
+#include "bladerunner/combat.h"
#include "bladerunner/gameflags.h"
#include "bladerunner/gameinfo.h"
#include "bladerunner/image.h"
+#include "bladerunner/items.h"
+#include "bladerunner/lights.h"
#include "bladerunner/mouse.h"
#include "bladerunner/outtake.h"
#include "bladerunner/scene.h"
@@ -45,8 +48,6 @@
#include "bladerunner/text_resource.h"
#include "bladerunner/vqa_decoder.h"
#include "bladerunner/waypoints.h"
-#include "bladerunner/items.h"
-#include "bladerunner/combat.h"
#include "common/array.h"
#include "common/error.h"
@@ -67,6 +68,7 @@ BladeRunnerEngine::BladeRunnerEngine(OSystem *syst)
_gameIsRunning = true;
_playerLosesControlCounter = 0;
+ _clues = NULL;
_script = new Script(this);
_settings = new Settings(this);
_lights = new Lights(this);
@@ -94,9 +96,6 @@ BladeRunnerEngine::~BladeRunnerEngine() {
// delete[] _zBuffer1;
// delete[] _zBuffer2;
- delete _combat;
- delete _waypoints;
- delete _lights;
delete _settings;
delete _script;
}
@@ -171,7 +170,7 @@ bool BladeRunnerEngine::startup(bool hasSavegames) {
// TODO: Sine and cosine lookup tables for intervals of 1.0, 4.0, and 12.0
- _view = new View(this);
+ _view = new View();
_sceneObjects = new SceneObjects(this, _view);
@@ -215,10 +214,13 @@ bool BladeRunnerEngine::startup(bool hasSavegames) {
assert(actorCount < 99);
for (int i = 0; i != actorCount; ++i) {
_actors[i] = new Actor(this, i);
+ _actors[i]->setup(i);
}
_voiceoverActor = new Actor(this, 99);
_playerActor = _actors[_gameInfo->getPlayerId()];
+ _playerActor->setFPS(15);
+
// TODO: set _playerActor countdown timer 6
// TODO: Set actor ids (redundant?)
@@ -310,6 +312,7 @@ bool BladeRunnerEngine::startup(bool hasSavegames) {
initScript.SCRIPT_Initialize_Game();
// TODO: Load AI-ACT1.DLL
+ _aiScripts = new AIScripts(this);
initChapterAndScene();
@@ -318,6 +321,11 @@ bool BladeRunnerEngine::startup(bool hasSavegames) {
void BladeRunnerEngine::initChapterAndScene() {
// TODO: Init actors...
+ for (int i = 0, end = _gameInfo->getActorCount(); i != end; ++i)
+ _aiScripts->Initialize(i);
+
+ for (int i = 0, end = _gameInfo->getActorCount(); i != end; ++i)
+ _actors[i]->changeAnimationMode(i);
_settings->setChapter(1);
_settings->setNewSetAndScene(_gameInfo->getInitialSetId(), _gameInfo->getInitialSceneId());
@@ -424,7 +432,8 @@ void BladeRunnerEngine::shutdown() {
delete[] _gameVars;
_gameVars = 0;
- // TODO: Delete World waypoints
+ delete _waypoints;
+ _waypoints = 0;
// TODO: Delete Cover waypoints
@@ -488,7 +497,7 @@ void BladeRunnerEngine::gameLoop() {
do {
/* TODO: check player death */
gameTick();
- } while (_gameIsRunning && !shouldQuit());
+ } while (_gameIsRunning);
}
void BladeRunnerEngine::gameTick() {
@@ -505,7 +514,10 @@ void BladeRunnerEngine::gameTick() {
// TODO: VK
// TODO: Elevators
// TODO: Scores
- // TODO: Call Script_Player_Walked_In if applicable
+
+ if (_scene->didPlayerWalkIn()) {
+ _script->PlayerWalkedIn();
+ }
// TODO: Gun range announcements
// TODO: ZBUF repair dirty rects
@@ -521,26 +533,45 @@ void BladeRunnerEngine::gameTick() {
_surface2.copyFrom(_surface1);
memcpy(_zBuffer2, _zBuffer1, 640*480*2);
- // TODO: Render overlays (mostly in Replicant)
- // TODO: Tick Actor AI and Timers (timers in Replicant)
+#if 0
+ {
+ for (int y = 0; y != 480; ++y) {
+ for (int x = 0; x != 640; ++x) {
+ if (_scene->_regions->getRegionAtXY(x, y) >= 0) {
+ uint16 *p = (uint16*)_surface2.getBasePtr(x, y);
+ *p = 0x7C00;
+ }
+ if (_scene->_exits->getRegionAtXY(x, y) >= 0) {
+ uint16 *p = (uint16*)_surface2.getBasePtr(x, y);
+ *p = 0x7C08;
+ }
+ }
+ }
+ }
+#endif
+
+ // TODO: Render overlays
+ // TODO: Tick Actor AI and Timers
if (_settings->getNewScene() == -1 || _script->_inScriptCounter /* || in_ai */) {
- // TODO: Tick and draw all actors in current set (drawing works in Replicant)
+ _sliceRenderer->setView(_scene->_view);
- // HACK to draw McCoy
- //_sliceRenderer->setView(&_scene->_view);
- _playerActor->draw();
+ // Tick and draw all actors in current set
+ for (int i = 0, end = _gameInfo->getActorCount(); i != end; ++i) {
+ if (i == 0 || i == 23) // Currently limited to McCoy and Officer Leroy
+ _actors[i]->tick(backgroundChanged);
+ }
- // TODO: Draw items (drawing works in Replicant)
- // TODO: Draw item pickup (understood, drawing works in Replicant)
+ // TODO: Draw items
+ // TODO: Draw item pickup
// TODO: Draw dialogue menu
Common::Point p = _eventMan->getMousePos();
_mouse->tick(p.x, p.y);
_mouse->draw(_surface2, p.x, p.y);
- // TODO: Process AUD (audio in Replicant)
+ // TODO: Process AUD
// TODO: Footstep sound
_system->copyRectToScreen((const byte *)_surface2.getBasePtr(0, 0), _surface2.pitch, 0, 0, 640, 480);
@@ -551,12 +582,60 @@ void BladeRunnerEngine::gameTick() {
}
void BladeRunnerEngine::handleEvents() {
+ if (shouldQuit()) {
+ _gameIsRunning = false;
+ return;
+ }
+
Common::Event event;
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_RBUTTONDOWN:
+ handleMouseClick(event.mouse.x, event.mouse.y);
+ default:
+ ;
+ }
}
}
+void BladeRunnerEngine::handleMouseClick(int x, int y) {
+ if (!playerHasControl() || _mouse->isDisabled())
+ return;
+
+ Vector3 mousePosition = _mouse->getXYZ(x, y);
+
+ int isClickable;
+ int isObstacle;
+ int isTarget;
+
+ int sceneObjectId = _sceneObjects->findByXYZ(&isClickable, &isObstacle, &isTarget, mousePosition.x, mousePosition.y, mousePosition.z, 1, 0, 1);
+ int exitType = _scene->_exits->getTypeAtXY(x, y);
+
+ debug("%d %d", sceneObjectId, exitType);
+
+ if ((sceneObjectId < 0 || sceneObjectId > 73) && exitType >= 0) {
+ // clickedOnExit(exitType, x, y);
+ debug("clicked on exit %d %d %d", exitType, x, y);
+ return;
+ }
+
+ int regionIndex = _scene->_regions->getRegionAtXY(x, y);
+ if (regionIndex >= 0) {
+ debug("clicked on region %d %d %d", regionIndex, x, y);
+ _script->ClickedOn2DRegion(regionIndex);
+ }
+
+ if (sceneObjectId >= 198 && sceneObjectId <= 293) {
+ const char *objectName = _scene->objectGetName(sceneObjectId - 198);
+ debug("%s", objectName);
+ _script->ClickedOn3DObject(objectName);
+ return;
+ }
+
+}
+
void BladeRunnerEngine::gameWaitForActive() {
while(!_windowIsActive) {
handleEvents();
@@ -571,11 +650,17 @@ void BladeRunnerEngine::loopActorSpeaking() {
do {
gameTick();
- } while (_audioSpeech->isPlaying());
+ } while (_gameIsRunning && _audioSpeech->isPlaying());
playerGainsControl();
}
+void BladeRunnerEngine::loopActorWalkToXYZ(int actorId, float x, float y, float z, int a4, int a5, int a6, int a7) {
+ Actor *actor = _actors[actorId];
+
+ actor->loopWalkToXYZ(Vector3(x, y, z));
+}
+
void BladeRunnerEngine::outtakePlay(int id, bool noLocalization, int container) {
Common::String name = _gameInfo->getOuttake(id);
@@ -655,7 +740,7 @@ void BladeRunnerEngine::playerLosesControl() {
if (++_playerLosesControlCounter == 1) {
_mouse->disable();
}
- debug("Player Lost Control (%d)", _playerLosesControlCounter);
+ // debug("Player Lost Control (%d)", _playerLosesControlCounter);
}
void BladeRunnerEngine::playerGainsControl() {
@@ -666,7 +751,7 @@ void BladeRunnerEngine::playerGainsControl() {
if (_playerLosesControlCounter > 0)
--_playerLosesControlCounter;
- debug("Player Gained Control (%d)", _playerLosesControlCounter);
+ // debug("Player Gained Control (%d)", _playerLosesControlCounter);
if (_playerLosesControlCounter == 0) {
_mouse->enable();
diff --git a/engines/bladerunner/bladerunner.h b/engines/bladerunner/bladerunner.h
index e90889adb8..fba793c116 100644
--- a/engines/bladerunner/bladerunner.h
+++ b/engines/bladerunner/bladerunner.h
@@ -37,13 +37,17 @@
namespace BladeRunner {
class Actor;
+class AIScripts;
class AmbientSounds;
class AudioPlayer;
class AudioSpeech;
class Chapters;
class Clues;
-class GameInfo;
+class Combat;
class GameFlags;
+class GameInfo;
+class Items;
+class Lights;
class Mouse;
class Scene;
class SceneObjects;
@@ -53,12 +57,8 @@ class Shape;
class SliceAnimations;
class SliceRenderer;
class TextResource;
-class Lights;
class View;
class Waypoints;
-class Items;
-class Combat;
-
class BladeRunnerEngine : public Engine {
public:
@@ -66,6 +66,7 @@ public:
bool _windowIsActive;
int _playerLosesControlCounter;
+ AIScripts *_aiScripts;
AmbientSounds *_ambientSounds;
AudioPlayer *_audioPlayer;
AudioSpeech *_audioSpeech;
@@ -74,13 +75,13 @@ public:
GameFlags *_gameFlags;
GameInfo *_gameInfo;
Mouse *_mouse;
- View *_view;
Scene *_scene;
SceneObjects *_sceneObjects;
Script *_script;
Settings *_settings;
SliceAnimations *_sliceAnimations;
SliceRenderer *_sliceRenderer;
+ View *_view;
int *_gameVars;
Lights *_lights;
@@ -118,7 +119,7 @@ public:
int _gameAutoSave;
bool _gameIsLoading;
bool _sceneIsLoading;
-
+
private:
static const int kArchiveCount = 10;
MIXArchive _archives[kArchiveCount];
@@ -137,13 +138,16 @@ public:
bool loadSplash();
bool init2();
-
+
void gameLoop();
void gameTick();
void handleEvents();
+ void handleMouseClick(int x, int y);
void gameWaitForActive();
void loopActorSpeaking();
+ void loopActorWalkToXYZ(int actorId, float x, float y, float z, int a4, int a5, int a6, int a7);
+
void outtakePlay(int id, bool no_localization, int container = -1);
bool openArchive(const Common::String &name);
diff --git a/engines/bladerunner/boundingbox.cpp b/engines/bladerunner/boundingbox.cpp
index 9b36eabe29..029442668f 100644
--- a/engines/bladerunner/boundingbox.cpp
+++ b/engines/bladerunner/boundingbox.cpp
@@ -44,16 +44,13 @@ void BoundingBox::expand(float x0, float y0, float z0, float x1, float y1, float
_vertices[1].z += z1;
}
-
bool BoundingBox::inside(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;
+ 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;
}
-
-void BoundingBox::setXyz(float x0, float y0, float z0, float x1, float y1, float z1) {
+void BoundingBox::setXYZ(float x0, float y0, float z0, float x1, float y1, float z1) {
_vertices[0].x = x0;
_vertices[0].y = y0;
_vertices[0].z = z0;
@@ -63,7 +60,7 @@ void BoundingBox::setXyz(float x0, float y0, float z0, float x1, float y1, float
_vertices[1].z = z1;
}
-void BoundingBox::getXyz(float *x0, float *y0, float *z0, float *x1, float *y1, float *z1) {
+void BoundingBox::getXYZ(float *x0, float *y0, float *z0, float *x1, float *y1, float *z1) {
*x0 = _vertices[0].x;
*y0 = _vertices[0].y;
*z0 = _vertices[0].z;
@@ -73,7 +70,6 @@ void BoundingBox::getXyz(float *x0, float *y0, float *z0, float *x1, float *y1,
*z1 = _vertices[1].z;
}
-
float BoundingBox::getZ0() {
return _vertices[0].z;
}
@@ -81,4 +77,5 @@ float BoundingBox::getZ0() {
float BoundingBox::getZ1() {
return _vertices[1].z;
}
+
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/boundingbox.h b/engines/bladerunner/boundingbox.h
index d9f7df6141..5031ce555f 100644
--- a/engines/bladerunner/boundingbox.h
+++ b/engines/bladerunner/boundingbox.h
@@ -23,12 +23,11 @@
#ifndef BLADERUNNER_BOUNDING_BOX_H
#define BLADERUNNER_BOUNDING_BOX_H
-#include "vector.h"
+#include "bladerunner/vector.h"
namespace BladeRunner {
class BoundingBox {
-private:
Vector3 _vertices[2];
public:
@@ -37,8 +36,10 @@ public:
void expand(float x0, float y0, float z0, float x1, float y1, float z1);
bool inside(float x, float y, float z);
- void setXyz(float x0, float y0, float z0, float x1, float y1, float z1);
- void getXyz(float* x0, float* y0, float* z0, float* x1, float* y1, float* z1);
+
+ void setXYZ(float x0, float y0, float z0, float x1, float y1, float z1);
+ void getXYZ(float* x0, float* y0, float* z0, float* x1, float* y1, float* z1);
+
float getZ0();
float getZ1();
};
diff --git a/engines/bladerunner/clues.cpp b/engines/bladerunner/clues.cpp
index 5b1ce97256..cbdf536c6d 100644
--- a/engines/bladerunner/clues.cpp
+++ b/engines/bladerunner/clues.cpp
@@ -23,11 +23,12 @@
#include "bladerunner/clues.h"
#include "bladerunner/bladerunner.h"
+
#include "bladerunner/text_resource.h"
namespace BladeRunner {
-Clues::Clues(BladeRunnerEngine *vm, const char *cluesResource, uint32 clueCount)
+Clues::Clues(BladeRunnerEngine *vm, const char *cluesResource, int clueCount)
: _clueCount(clueCount)
{
// reset();
@@ -38,14 +39,14 @@ Clues::Clues(BladeRunnerEngine *vm, const char *cluesResource, uint32 clueCount)
_cluesText = new TextResource(vm);
_cluesText->open(cluesResource);
- for (uint32 i = 0; i != _clueCount; ++i) {
+ for (int i = 0; i != _clueCount; ++i) {
_crimes[i] = -1;
_assetTypes[i] = -1;
}
}
Clues::~Clues() {
- delete _cluesText;
+ delete _cluesText;
delete[] _assetTypes;
delete[] _crimes;
}
diff --git a/engines/bladerunner/clues.h b/engines/bladerunner/clues.h
index 2ffcbd20cd..4afdef682e 100644
--- a/engines/bladerunner/clues.h
+++ b/engines/bladerunner/clues.h
@@ -23,21 +23,19 @@
#ifndef BLADERUNNER_CLUES_H
#define BLADERUNNER_CLUES_H
-#include "common/scummsys.h"
-
namespace BladeRunner {
class BladeRunnerEngine;
class TextResource;
class Clues {
- uint32 _clueCount;
+ int _clueCount;
int *_crimes;
int *_assetTypes;
TextResource *_cluesText;
public:
- Clues(BladeRunnerEngine *vm, const char *cluesResource, uint32 clueCount);
+ Clues(BladeRunnerEngine *vm, const char *cluesResource, int clueCount);
~Clues();
const char *getClueText(int id);
diff --git a/engines/bladerunner/color.h b/engines/bladerunner/color.h
index 54983b401b..eebe2dcdc0 100644
--- a/engines/bladerunner/color.h
+++ b/engines/bladerunner/color.h
@@ -1,37 +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.
-*
-*/
+ *
+ * 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;
- };
-}
+struct Color
+{
+ float r;
+ float g;
+ float b;
+};
+} // End of namespace BladeRunner
#endif
diff --git a/engines/bladerunner/combat.cpp b/engines/bladerunner/combat.cpp
index 5fe2e3f36e..1f61d7bacc 100644
--- a/engines/bladerunner/combat.cpp
+++ b/engines/bladerunner/combat.cpp
@@ -1,19 +1,23 @@
#include "bladerunner/combat.h"
+
#include "bladerunner/bladerunner.h"
+
#include "bladerunner/actor.h"
#include "bladerunner/settings.h"
namespace BladeRunner {
-
Combat::Combat(BladeRunnerEngine* vm) {
_vm = vm;
_active = false;
_enabled = true;
- int i;
- for (i = 0; i < 9; i++) {
+ _ammoDamage[0] = 10;
+ _ammoDamage[1] = 20;
+ _ammoDamage[2] = 30;
+
+ for (int i = 0; i < 9; i++) {
_hitSoundId[i] = -1;
_missSoundId[i] = -1;
}
@@ -48,7 +52,6 @@ void Combat::disable() {
_enabled = false;
}
-
void Combat::setHitSoundId(int row, int column, int soundId) {
_hitSoundId[row * 3 + column] = soundId;
}
@@ -56,4 +59,5 @@ void Combat::setHitSoundId(int row, int column, int soundId) {
void Combat::setMissSoundId(int row, int column, int soundId) {
_missSoundId[row * 3 + column] = soundId;
}
-} \ No newline at end of file
+
+} // End of namespace BladeRunner
diff --git a/engines/bladerunner/combat.h b/engines/bladerunner/combat.h
index 5860fd76d0..79de69d726 100644
--- a/engines/bladerunner/combat.h
+++ b/engines/bladerunner/combat.h
@@ -23,10 +23,10 @@
#ifndef BLADERUNNER_COMBAT_H
#define BLADERUNNER_COMBAT_H
-#include "bladerunner/bladerunner.h"
-
namespace BladeRunner {
+class BladeRunnerEngine;
+
class Combat {
BladeRunnerEngine *_vm;
@@ -38,7 +38,7 @@ class Combat {
int _random2;
public:
- int _ammoDamage[3] = { 10, 20, 30 };
+ int _ammoDamage[3];
public:
Combat(BladeRunnerEngine *vm);
@@ -53,9 +53,8 @@ public:
void setHitSoundId(int row, int column, int soundId);
void setMissSoundId(int row, int column, int soundId);
-
};
-}
+} // End of namespace BladeRunner
#endif
diff --git a/engines/bladerunner/detection_tables.h b/engines/bladerunner/detection_tables.h
index 90f27ffbee..940c854ce6 100644
--- a/engines/bladerunner/detection_tables.h
+++ b/engines/bladerunner/detection_tables.h
@@ -42,6 +42,6 @@ static const ADGameDescription gameDescriptions[] = {
AD_TABLE_END_MARKER
};
-} // End of namespace Hopkins
+} // End of namespace BladeRunner
#endif
diff --git a/engines/bladerunner/fog.cpp b/engines/bladerunner/fog.cpp
index 5951ba8d1c..ead7c91db2 100644
--- a/engines/bladerunner/fog.cpp
+++ b/engines/bladerunner/fog.cpp
@@ -1,94 +1,96 @@
#include "bladerunner/fog.h"
-namespace BladeRunner
+#include "common/stream.h"
+
+namespace BladeRunner {
+
+Fog::Fog()
{
- Fog::Fog()
- {
- }
+}
- 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;
- }
+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);
- 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);
+ _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);
- }
+ setupFrame(0);
+}
- void Fog::reset()
- {
- }
+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 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 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 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);
+}
- 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
+} // End of namespace BladeRunner
diff --git a/engines/bladerunner/fog.h b/engines/bladerunner/fog.h
index 627e8f15bd..db291e3b62 100644
--- a/engines/bladerunner/fog.h
+++ b/engines/bladerunner/fog.h
@@ -1,104 +1,102 @@
/* 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.
-*
-*/
+ *
+ * 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 Common {
+ class ReadStream;
+}
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);
- };
-
+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();
+ virtual ~Fog();
+
+ virtual void read(Common::ReadStream *stream, int framesCount) = 0;
+
+ void reset();
+
+ void setupFrame(int frame);
+
+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);
+};
+
+} // End of namespace BladeRunner
-
-}
#endif
diff --git a/engines/bladerunner/gameflags.cpp b/engines/bladerunner/gameflags.cpp
index 3704271e04..087292e39f 100644
--- a/engines/bladerunner/gameflags.cpp
+++ b/engines/bladerunner/gameflags.cpp
@@ -38,8 +38,6 @@ GameFlags::~GameFlags() {
void GameFlags::setFlagCount(int count) {
assert(count > 0);
- debug("flagCount: %d", count);
-
flagCount = count;
flags = new uint32[count / 32 + 1];
@@ -48,18 +46,21 @@ void GameFlags::setFlagCount(int count) {
}
void GameFlags::set(int flag) {
+ debug("GameFlags::set(%d)", flag);
assert(flag >= 0 && flag <= flagCount);
flags[flag / 32] |= (1 << (flag % 32));
}
void GameFlags::reset(int flag) {
+ debug("GameFlags::reset(%d)", flag);
assert(flag >= 0 && flag <= flagCount);
flags[flag / 32] &= ~(1 << (flag % 32));
}
bool GameFlags::query(int flag) {
+ debug("GameFlags::query(%d): %d", flag, !!(flags[flag / 32] & (1 << (flag % 32))));
assert(flag >= 0 && flag <= flagCount);
return !!(flags[flag / 32] & (1 << (flag % 32)));
diff --git a/engines/bladerunner/image.cpp b/engines/bladerunner/image.cpp
index 157e443384..abdd6ffe7e 100644
--- a/engines/bladerunner/image.cpp
+++ b/engines/bladerunner/image.cpp
@@ -23,6 +23,7 @@
#include "bladerunner/image.h"
#include "bladerunner/bladerunner.h"
+
#include "bladerunner/decompress_lcw.h"
#include "common/rect.h"
diff --git a/engines/bladerunner/image.h b/engines/bladerunner/image.h
index 75991d0f55..376f9962a9 100644
--- a/engines/bladerunner/image.h
+++ b/engines/bladerunner/image.h
@@ -23,11 +23,12 @@
#ifndef BLADERUNNER_IMAGE_H
#define BLADERUNNER_IMAGE_H
-#include "common/debug.h"
-#include "common/substream.h"
-
#include "graphics/surface.h"
+namespace Common {
+ class String;
+}
+
namespace BladeRunner {
class BladeRunnerEngine;
diff --git a/engines/bladerunner/item.cpp b/engines/bladerunner/item.cpp
index 7a3ec925aa..7017997e90 100644
--- a/engines/bladerunner/item.cpp
+++ b/engines/bladerunner/item.cpp
@@ -11,10 +11,10 @@ Item::Item() {
Item::~Item() {
}
-
-void Item::getXyz(float* x, float* y, float* z) {
+void Item::getXYZ(float *x, float *y, float *z) {
*x = _position.x;
*y = _position.y;
*z = _position.z;
}
-} \ No newline at end of file
+
+} // End of namespace BladeRunner
diff --git a/engines/bladerunner/item.h b/engines/bladerunner/item.h
index a4a9282f20..5bb8e5481a 100644
--- a/engines/bladerunner/item.h
+++ b/engines/bladerunner/item.h
@@ -1,24 +1,24 @@
/* 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.
-*
-*/
+ *
+ * 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_ITEM_H
#define BLADERUNNER_ITEM_H
@@ -59,7 +59,7 @@ namespace BladeRunner {
Item();
~Item();
- void getXyz(float *x, float *y, float *z);
+ void getXYZ(float *x, float *y, float *z);
};
}
diff --git a/engines/bladerunner/items.cpp b/engines/bladerunner/items.cpp
index be03b9beaf..da3e74c69a 100644
--- a/engines/bladerunner/items.cpp
+++ b/engines/bladerunner/items.cpp
@@ -9,20 +9,19 @@ Items::Items(BladeRunnerEngine *vm) {
Items::~Items() {
}
-
-void Items::getXyz(int itemId, float* x, float* y, float* z) {
+void Items::getXYZ(int itemId, float* x, float* y, float* z) {
int itemIndex = findItem(itemId);
assert(itemIndex != -1);
- _items[itemIndex].getXyz(x, y, z);
+ _items[itemIndex].getXYZ(x, y, z);
}
int Items::findItem(int itemId) {
- int i;
- for (i = 0; i < (int)_items.size(); i++) {
+ for (int i = 0; i < (int)_items.size(); i++) {
if (_items[i]._itemId == itemId)
return i;
}
return -1;
}
-} \ No newline at end of file
+
+} // End of namespace BladeRunner
diff --git a/engines/bladerunner/items.h b/engines/bladerunner/items.h
index 39f574cacc..08d2a2b958 100644
--- a/engines/bladerunner/items.h
+++ b/engines/bladerunner/items.h
@@ -1,24 +1,24 @@
/* 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.
-*
-*/
+ *
+ * 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_ITEMS_H
#define BLADERUNNER_ITEMS_H
@@ -29,22 +29,24 @@
#include "common/array.h"
#include "common/rect.h"
-namespace BladeRunner {
+namespace BladeRunner {
- class Items {
- BladeRunnerEngine *_vm;
- private:
- Common::Array<Item> _items;
+class Items {
+ BladeRunnerEngine *_vm;
- public:
- Items(BladeRunnerEngine *vm);
- ~Items();
-
- void getXyz(int itemId, float *x, float *y, float *z);
+private:
+ Common::Array<Item> _items;
- private:
- int findItem(int itemId);
- };
-}
+public:
+ Items(BladeRunnerEngine *vm);
+ ~Items();
+
+ void getXYZ(int itemId, float *x, float *y, float *z);
+
+private:
+ int findItem(int itemId);
+};
+
+} // End of namespace BladeRunner
#endif
diff --git a/engines/bladerunner/light.cpp b/engines/bladerunner/light.cpp
index 6bc97f8392..3689ab42ce 100644
--- a/engines/bladerunner/light.cpp
+++ b/engines/bladerunner/light.cpp
@@ -1,84 +1,85 @@
#include "bladerunner/light.h"
-namespace BladeRunner
+namespace BladeRunner {
+
+Light::Light()
{
- Light::Light()
- {
- }
+}
- Light::~Light()
- {
- }
+Light::~Light()
+{
+}
- void Light::read(Common::ReadStream* stream, int framesCount, int frame, int animated)
- {
- _framesCount = framesCount;
- _animated = animated;
+void Light::read(Common::ReadStream* stream, int framesCount, int frame, int animated)
+{
+ _framesCount = framesCount;
+ _animated = animated;
- int size = stream->readUint32LE();
- size = size - 32;
+ int size = stream->readUint32LE();
+ size = size - 32;
- stream->read(_name, 20);
+ stream->read(_name, 20);
- _animatedParameters = stream->readUint32LE();
+ _animatedParameters = stream->readUint32LE();
- _animationData = new float[size / sizeof(float)];
- stream->read(_animationData, size);
+ _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);
+ _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);
- }
+ setupFrame(frame);
+}
- void Light::readVqa(Common::ReadStream* stream)
- {
- }
+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);
+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;
+}
- float Light::attenuation(float min, float max, float distance)
- {
- return 0.0;
- }
-} \ No newline at end of file
+} // End of namespace BladeRunner
diff --git a/engines/bladerunner/light.h b/engines/bladerunner/light.h
index f4c142e4ab..bfece071dc 100644
--- a/engines/bladerunner/light.h
+++ b/engines/bladerunner/light.h
@@ -33,72 +33,77 @@ namespace Common{
}
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 {
-
- };
-}
+
+class Lights;
+
+class Light
+{
+ friend class Lights;
+
+ 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 {
+
+};
+
+} // End of namespace BladeRunner
#endif
diff --git a/engines/bladerunner/lights.cpp b/engines/bladerunner/lights.cpp
index 33ee3d1181..29e4c2f58e 100644
--- a/engines/bladerunner/lights.cpp
+++ b/engines/bladerunner/lights.cpp
@@ -1,100 +1,101 @@
#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::Lights(BladeRunnerEngine *vm)
+{
+ _vm = vm;
- _lights = NULL;
- _frame = 0;
- }
+ _ambientLightColor.r = 1.0;
+ _ambientLightColor.g = 0.0;
+ _ambientLightColor.b = 0.0;
- Lights::~Lights()
- {
- reset();
- }
+ _lights = NULL;
+ _frame = 0;
+}
- void Lights::read(Common::ReadStream* stream, int framesCount)
- {
- _ambientLightColor.r = stream->readFloatLE();
- _ambientLightColor.g = stream->readFloatLE();
- _ambientLightColor.b = stream->readFloatLE();
+Lights::~Lights()
+{
+ reset();
+}
- _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::read(Common::ReadStream* stream, int framesCount)
+{
+ _ambientLightColor.r = stream->readFloatLE();
+ _ambientLightColor.g = stream->readFloatLE();
+ _ambientLightColor.b = stream->readFloatLE();
- void Lights::readVqa(Common::ReadStream* stream)
+ _lightsCount = stream->readUint32LE();
+ int i;
+ for (i = 0; i < _lightsCount; i++)
{
- reset();
- //int framesCount = stream->readUint32LE();
- //int count = stream->readUint32LE();
+ 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::setupFrame(int frame)
- {
- Light *light;
+void Lights::readVqa(Common::ReadStream* stream)
+{
+ reset();
+ //int framesCount = stream->readUint32LE();
+ //int count = stream->readUint32LE();
+}
- if (frame == _frame)
- return;
+void Lights::setupFrame(int frame)
+{
+ Light *light;
- if (!_lights)
- return;
+ if (frame == _frame)
+ return;
- for (light = _lights; light; light = light->_next)
- {
- light->setupFrame(frame);
- }
- }
+ if (!_lights)
+ return;
- void Lights::reset()
+ for (light = _lights; light; light = light->_next)
{
- Light *light;
- Light *nextLight;
+ light->setupFrame(frame);
+ }
+}
- if (!_lights)
- return;
+void Lights::reset()
+{
+ Light *light;
+ Light *nextLight;
- do
- {
- light = _lights;
- nextLight = light->_next;
- delete light;
- _lights = nextLight;
- } while (nextLight);
- }
-} \ No newline at end of file
+ if (!_lights)
+ return;
+
+ do
+ {
+ light = _lights;
+ nextLight = light->_next;
+ delete light;
+ _lights = nextLight;
+ } while (nextLight);
+}
+
+} // End of namespace BladeRunner
diff --git a/engines/bladerunner/lights.h b/engines/bladerunner/lights.h
index d6ff7f5261..71e6d21b2f 100644
--- a/engines/bladerunner/lights.h
+++ b/engines/bladerunner/lights.h
@@ -29,36 +29,31 @@
#include "common/stream.h"
-
namespace BladeRunner {
- class Lights
- {
- BladeRunnerEngine *_vm;
+class Lights {
+ BladeRunnerEngine *_vm;
- private:
- Color _ambientLightColor;
+ Color _ambientLightColor;
- int _lightsCount;
- Light *_lights;
-
- int _frame;
- //char gap[28];
+ int _lightsCount;
+ Light *_lights;
- public:
- Lights(BladeRunnerEngine *vm);
- ~Lights();
+ int _frame;
+ //char gap[28];
- void read(Common::ReadStream *stream, int framesCount);
- void readVqa(Common::ReadStream *stream);
+public:
+ Lights(BladeRunnerEngine *vm);
+ ~Lights();
- void reset();
+ void read(Common::ReadStream *stream, int framesCount);
+ void readVqa(Common::ReadStream *stream);
- void setupFrame(int frame);
+ void reset();
- private:
+ void setupFrame(int frame);
+};
- };
+} // End of namespace BladeRunner
-}
#endif
diff --git a/engines/bladerunner/matrix.cpp b/engines/bladerunner/matrix.cpp
index fae8e43d19..db4d4d5f9a 100644
--- a/engines/bladerunner/matrix.cpp
+++ b/engines/bladerunner/matrix.cpp
@@ -166,16 +166,20 @@ Matrix4x3 invertMatrix(const Matrix4x3 &m)
return result;
}
-
void Matrix4x3::unknown()
{
- float m14 = _m[0][3];
- float m24 = _m[1][3];
- float m34 = _m[2][3];
+ Matrix4x3 t;
- _m[0][3] = -(m34 * _m[0][2]) - m24 * _m[0][1] - m14 * _m[0][0];
- _m[1][3] = -(m34 * _m[1][2]) - m24 * _m[1][1] - m14 * _m[1][0];
- _m[2][3] = -(m34 * _m[2][2]) - m24 * _m[2][1] - m14 * _m[2][0];
+ // Transpose the 3x3 top left submatrix
+ for (int r = 0; r != 3; ++r)
+ for (int c = 0; c != 3; ++c)
+ t(r, c) = _m[c][r];
+ t(0,3) = -(_m[0][3] * _m[0][0] + _m[1][3] * _m[1][0] + _m[2][3] * _m[2][0]);
+ t(1,3) = -(_m[0][3] * _m[0][1] + _m[1][3] * _m[1][1] + _m[2][3] * _m[2][1]);
+ t(2,3) = -(_m[0][3] * _m[0][2] + _m[1][3] * _m[1][2] + _m[2][3] * _m[2][2]);
+
+ *this = t;
}
+
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/matrix.h b/engines/bladerunner/matrix.h
index cb7bc2f08e..4450306dad 100644
--- a/engines/bladerunner/matrix.h
+++ b/engines/bladerunner/matrix.h
@@ -93,6 +93,7 @@ public:
float &operator()(int r, int c) { assert(r >= 0 && r < 3); assert(c >= 0 && c < 4); return _m[r][c]; }
const float &operator()(int r, int c) const { assert(r >= 0 && r < 3); assert(c >= 0 && c < 4); return _m[r][c]; }
+
void unknown();
};
@@ -128,8 +129,6 @@ Vector3 operator*(const Matrix4x3 &m, const Vector3 &v)
return r;
}
-
-
} // End of namespace BladeRunner
#endif
diff --git a/engines/bladerunner/module.mk b/engines/bladerunner/module.mk
index 7ec48f6a7e..e6b8e43584 100644
--- a/engines/bladerunner/module.mk
+++ b/engines/bladerunner/module.mk
@@ -2,6 +2,9 @@ MODULE := engines/bladerunner
MODULE_OBJS = \
actor.o \
+ actor_clues.o \
+ actor_combat.o \
+ actor_walk.o \
adpcm_decoder.o \
ambient_sounds.o \
archive.o \
@@ -12,28 +15,41 @@ MODULE_OBJS = \
boundingbox.o \
chapters.o \
clues.o \
+ combat.o \
decompress_lcw.o \
decompress_lzo.o \
detection.o \
+ fog.o \
gameflags.o \
gameinfo.o \
image.o \
+ item.o \
+ items.o \
+ light.o \
+ lights.o \
matrix.o \
mouse.o \
+ movement_track.o \
outtake.o \
+ regions.o \
scene.o \
+ scene_objects.o \
+ script/ai_00_mccoy.o \
+ script/aiscript_officer_leroy.o \
script/init.o \
script/rc01.o \
script/script.o \
set.o \
settings.o \
+ set_effects.o \
shape.o \
slice_animations.o \
slice_renderer.o \
text_resource.o \
view.o \
vqa_decoder.o \
- vqa_player.o
+ vqa_player.o \
+ waypoints.o
# This module can be built as a plugin
ifeq ($(ENABLE_BLADERUNNER), DYNAMIC_PLUGIN)
diff --git a/engines/bladerunner/mouse.cpp b/engines/bladerunner/mouse.cpp
index 64c64b2435..ba747c2e94 100644
--- a/engines/bladerunner/mouse.cpp
+++ b/engines/bladerunner/mouse.cpp
@@ -23,11 +23,11 @@
#include "bladerunner/mouse.h"
#include "bladerunner/bladerunner.h"
-#include "bladerunner/shape.h"
#include "bladerunner/scene.h"
+#include "bladerunner/scene_objects.h"
+#include "bladerunner/shape.h"
#include "graphics/surface.h"
-#include "common/rect.h"
namespace BladeRunner {
@@ -169,7 +169,6 @@ void Mouse::draw(Graphics::Surface &surface, int x, int y) {
_x = CLIP(x, 0, surface.w - 1);
_y = CLIP(y, 0, surface.h - 1);
-
if (_cursor < 0 || (uint)_cursor >= _vm->_shapes.size()) {
return;
}
@@ -254,43 +253,78 @@ void Mouse::tick(int x, int y)
if (!_vm->playerHasControl() || isDisabled())
return;
- Vector3 mousePosition;
+ Vector3 mousePosition = getXYZ(x, y);
+ int cursorId = 0;
- getXYZ(x, y, &mousePosition);
int isClickable = 0;
- int isObstacle = 0;
- int isCombatTarget = 0;
- int sceneObjectId = _vm->_sceneObjects->findByXYZ(&isClickable, &isObstacle, &isCombatTarget, mousePosition.x, mousePosition.y, mousePosition.z, 1, 0, 1);
- //debug("mouse tick: objectid = %d", sceneObjectId);
+ int isObstacle = 0;
+ int isTarget = 0;
+
+ int sceneObjectId = _vm->_sceneObjects->findByXYZ(&isClickable, &isObstacle, &isTarget, mousePosition.x, mousePosition.y, mousePosition.z, 1, 0, 1);
+ int exitType = _vm->_scene->_exits->getTypeAtXY(x, y);
+
+ if (sceneObjectId >= 0 && sceneObjectId <= 74) {
+ exitType = -1;
+ }
+
+ if (exitType != -1) {
+ switch (exitType) {
+ case 1:
+ cursorId = 13;
+ break;
+ case 2:
+ cursorId = 14;
+ break;
+ case 3:
+ cursorId = 15;
+ break;
+ default:
+ cursorId = 12;
+ }
+ setCursor(cursorId);
+ return;
+ }
+
+ if (true /* not in combat */) {
+ if (sceneObjectId == 0
+ || (sceneObjectId >= 0 && isClickable)
+ || _vm->_scene->_regions->getRegionAtXY(x, y) >= 0)
+ {
+ cursorId = 1;
+ }
+ setCursor(cursorId);
+ return;
+ }
+
+ setCursor(cursorId);
}
-void Mouse::getXYZ(int x, int y, Vector3* mousePosition)
+// TEST: RC01 after intro: [290, 216] -> [-204.589249 51.450668 7.659241]
+Vector3 Mouse::getXYZ(int x, int y)
{
- if (_vm->_scene->_setId == -1)
- return;
+ if (_vm->_scene->getSetId() == -1)
+ return Vector3();
int screenRight = 640 - x;
- int screenDown = 480 - y;
-
- float zcoef = 1.0f / tan(_vm->_view->_fovX / 2.0f);
+ int screenDown = 480 - y;
+
+ float zcoef = 1.0f / tan(_vm->_scene->_view._fovX / 2.0f);
+
+ float x3d = (2.0f / 640.0f * screenRight - 1.0f);
+ float y3d = (2.0f / 480.0f * screenDown - 1.0f) * 0.75f;
- float x3d = (2.0f / 640.0f * screenRight - 1) * zcoef / (1*zcoef);
- float y3d = (2.0f / 480.0f * screenDown- 1) / (4/3 * zcoef) * zcoef;
+ uint16 zbufval = _vm->_zBuffer1[x + y * 640];
- uint16 zbufval = _vm->_zBuffer1[x + y * 480];
+ Vector3 pos;
+ pos.z = zbufval / 25.5f;
+ pos.x = pos.z / zcoef * x3d;
+ pos.y = pos.z / zcoef * y3d;
- Vector3 vector;
- vector.z = zbufval / 25.5f;
- vector.x = vector.z / zcoef * x3d;
- vector.y = vector.z / zcoef * y3d;
+ Matrix4x3 matrix = _vm->_scene->_view._frameViewMatrix;
- Matrix4x3 matrix = _vm->_view->_frameViewMatrix;
matrix.unknown();
- vector = matrix * vector;
- mousePosition->x = vector.x;
- mousePosition->y = vector.y;
- mousePosition->z = vector.z;
+ return matrix * pos;
}
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/mouse.h b/engines/bladerunner/mouse.h
index d708960602..8fb5f324a2 100644
--- a/engines/bladerunner/mouse.h
+++ b/engines/bladerunner/mouse.h
@@ -23,14 +23,15 @@
#ifndef BLADERUNNER_MOUSE_H
#define BLADERUNNER_MOUSE_H
+#include "bladerunner/vector.h"
+
namespace Graphics {
struct Surface;
}
namespace BladeRunner {
- class Vector3;
- class BladeRunnerEngine;
+class BladeRunnerEngine;
class Mouse {
BladeRunnerEngine *_vm;
@@ -59,8 +60,9 @@ public:
void updateCursorFrame();
void tick(int x, int y);
-private:
- void Mouse::getXYZ(int x, int y, Vector3* mousePosition);
+
+// private:
+ Vector3 getXYZ(int x, int y);
};
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/movement_track.cpp b/engines/bladerunner/movement_track.cpp
index 01dff24422..0913e77fa2 100644
--- a/engines/bladerunner/movement_track.cpp
+++ b/engines/bladerunner/movement_track.cpp
@@ -23,102 +23,105 @@
#include "bladerunner/movement_track.h"
namespace BladeRunner {
- MovementTrack::MovementTrack()
- {
- reset();
- }
- MovementTrack::~MovementTrack()
- {
- reset();
- }
+MovementTrack::MovementTrack()
+{
+ reset();
+}
- void MovementTrack::reset()
- {
- _currentIndex = -1;
- _lastIndex = -1;
- _hasNext = 0;
- _paused = 0;
- for (int i = 0; i < 100; i++)
- {
- _entries[i].waypointId = -1;
- _entries[i].delay = -1;
- _entries[i].angle = -1;
- _entries[i].running = 0;
- }
- }
+MovementTrack::~MovementTrack()
+{
+ reset();
+}
- int MovementTrack::append(int waypointId, int delay, int running)
+void MovementTrack::reset()
+{
+ _currentIndex = -1;
+ _lastIndex = -1;
+ _hasNext = 0;
+ _paused = 0;
+ for (int i = 0; i < 100; i++)
{
- return append(waypointId, delay, -1, running);
+ _entries[i].waypointId = -1;
+ _entries[i].delay = -1;
+ _entries[i].angle = -1;
+ _entries[i].running = 0;
}
+}
- 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;
- }
+int MovementTrack::append(int waypointId, int delay, int running)
+{
+ return append(waypointId, delay, -1, running);
+}
- void MovementTrack::flush()
- {
- reset();
- }
+int MovementTrack::append(int waypointId, int delay, int angle, int running)
+{
+ if (_lastIndex > ARRAYSIZE(_entries))
+ return 0;
- void MovementTrack::repeat()
- {
- _currentIndex = 0;
- _hasNext = 1;
- }
+ _entries[_lastIndex].waypointId = waypointId;
+ _entries[_lastIndex].delay = delay;
+ _entries[_lastIndex].angle = angle;
+ _entries[_lastIndex].running = running;
- int MovementTrack::pause()
- {
- _paused = 1;
- return 1;
- }
+ _lastIndex++;
+ _hasNext = 1;
+ _currentIndex = 0;
+ return 1;
+}
- int MovementTrack::unpause()
- {
- _paused = 0;
- return 1;
- }
+void MovementTrack::flush()
+{
+ reset();
+}
- int MovementTrack::isPaused()
- {
- return _paused;
- }
+void MovementTrack::repeat()
+{
+ _currentIndex = 0;
+ _hasNext = 1;
+}
+
+int MovementTrack::pause()
+{
+ _paused = 1;
+ return 1;
+}
- int MovementTrack::hasNext()
+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)
{
- return _hasNext;
+ *waypointId = _entries[_currentIndex].waypointId;
+ *delay = _entries[_currentIndex].delay;
+ *angle = _entries[_currentIndex].angle;
+ *running = _entries[_currentIndex++].running;
+ return 1;
}
-
- int MovementTrack::next(int *waypointId, int *delay, int *angle, int *running)
+ else
{
- 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;
- }
+ *waypointId = -1;
+ *delay = -1;
+ *angle = -1;
+ *running = 0;
+ _hasNext = 0;
+ return 0;
}
-} \ No newline at end of file
+}
+
+} // End of namespace BladeRunner
diff --git a/engines/bladerunner/movement_track.h b/engines/bladerunner/movement_track.h
index 491de8051a..30ac07efb6 100644
--- a/engines/bladerunner/movement_track.h
+++ b/engines/bladerunner/movement_track.h
@@ -25,46 +25,46 @@
#include "bladerunner/bladerunner.h"
-
namespace BladeRunner {
- class BladeRunnerEngine;
- class BoundingBox;
+class BladeRunnerEngine;
+class BoundingBox;
+
+struct MovementTrackEntry
+{
+ int waypointId;
+ int delay;
+ int angle;
+ int running;
+};
- struct MovementTrackEntry
- {
- int waypointId;
- int delay;
- int angle;
- int running;
- };
+class MovementTrack {
+ BladeRunnerEngine *_vm;
- class MovementTrack {
- BladeRunnerEngine *_vm;
+private:
+ int _currentIndex;
+ int _lastIndex;
+ int _hasNext;
+ int _paused;
+ MovementTrackEntry _entries[100];
+ void reset();
- 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);
- 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();
+};
- //int saveGame();
- };
} // End of namespace BladeRunner
#endif
diff --git a/engines/bladerunner/outtake.cpp b/engines/bladerunner/outtake.cpp
index 3ffc964d03..b81b212f52 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, _vm->_view);
+ VQAPlayer vqa_player(_vm);
vqa_player.open(resName);
diff --git a/engines/bladerunner/regions.cpp b/engines/bladerunner/regions.cpp
index fe817e074b..f75be0ff1b 100644
--- a/engines/bladerunner/regions.cpp
+++ b/engines/bladerunner/regions.cpp
@@ -1,47 +1,84 @@
#include "bladerunner/regions.h"
namespace BladeRunner {
- Regions::Regions() {
- _enabled = true;
- _regions = new Region[10];
- }
- Regions::~Regions() {
- delete[] _regions;
- }
+Regions::Regions() {
+ _enabled = true;
+ _regions = new Region[10];
+ clear();
+}
- bool Regions::add(int index, Common::Rect rect, int type) {
- if (index <= 0 || index >= 10)
- return false;
+Regions::~Regions() {
+ delete[] _regions;
+}
- if (_regions[index]._present)
- return false;
+void BladeRunner::Regions::clear() {
+ for (int i = 0; i < 10; ++i)
+ remove(i);
+}
- _regions[index]._rectangle = rect;
- _regions[index]._type = type;
- _regions[index]._present = 1;
+bool Regions::add(int index, Common::Rect rect, int type) {
+ if (index < 0 || index >= 10)
+ return false;
- return true;
- }
+ if (_regions[index]._present)
+ return false;
- bool Regions::remove(int index) {
- if (index <= 0 || index >= 10)
- return false;
+ _regions[index]._rectangle = rect;
+ _regions[index]._type = type;
+ _regions[index]._present = 1;
- _regions[index]._rectangle = Common::Rect(-1, -1, -1, -1);
- _regions[index]._type = -1;
- _regions[index]._present = 0;
+ return true;
+}
- return true;
- }
+bool Regions::remove(int index) {
+ if (index < 0 || index >= 10)
+ return false;
- void BladeRunner::Regions::clear() {
- int i;
- for (i = 0; i < 10; i++)
- remove(i);
- }
+ _regions[index]._rectangle = Common::Rect(-1, -1, -1, -1);
+ _regions[index]._type = -1;
+ _regions[index]._present = 0;
+
+ return true;
+}
+
+int Regions::getTypeAtXY(int x, int y) {
+ int index = getRegionAtXY(x, y);
+
+ if (index == -1)
+ return -1;
- void Regions::setEnabled(bool enabled) {
- _enabled = enabled;
+ return _regions[index]._type;
+}
+
+int Regions::getRegionAtXY(int x, int y) {
+ if (!_enabled)
+ return -1;
+
+ for (int i = 0; i != 10; ++i) {
+ if (!_regions[i]._present)
+ continue;
+
+ // Common::Rect::contains is exclusive of right and bottom but
+ // Blade Runner wants inclusive, so we adjust the edges.
+ // TODO: Roll our own rect class?
+ Common::Rect r = _regions[i]._rectangle;
+ r.right++;
+ r.bottom++;
+
+ if (r.contains(x, y))
+ return i;
}
-} \ No newline at end of file
+
+ return -1;
+}
+
+void Regions::setEnabled(bool enabled) {
+ _enabled = enabled;
+}
+
+void Regions::enable() {
+ _enabled = true;
+}
+
+} // End of namespace BladeRunner
diff --git a/engines/bladerunner/regions.h b/engines/bladerunner/regions.h
index e92e812714..8a65aed5a4 100644
--- a/engines/bladerunner/regions.h
+++ b/engines/bladerunner/regions.h
@@ -27,29 +27,35 @@
#include "common/rect.h"
-
namespace BladeRunner {
- struct Region
- {
- Common::Rect _rectangle;
- int _type;
- int _present;
- };
-
- class Regions
- {
- private:
- Region* _regions;
- bool _enabled;
- public:
- Regions();
- ~Regions();
-
- bool add(int index, Common::Rect rect, int type);
- bool remove(int index);
- void clear();
-
- void setEnabled(bool enabled);
- };
-}
+
+struct Region
+{
+ Common::Rect _rectangle;
+ int _type;
+ int _present;
+};
+
+class Regions
+{
+private:
+ Region* _regions;
+ bool _enabled;
+public:
+ Regions();
+ ~Regions();
+
+ void clear();
+ bool add(int index, Common::Rect rect, int type);
+ bool remove(int index);
+
+ int getTypeAtXY(int x, int y);
+ int getRegionAtXY(int x, int y);
+
+ void setEnabled(bool enabled);
+ void enable();
+};
+
+} // End of namespace BladeRunner
+
#endif
diff --git a/engines/bladerunner/scene.cpp b/engines/bladerunner/scene.cpp
index 3c04ee8814..ba4ca44f1c 100644
--- a/engines/bladerunner/scene.cpp
+++ b/engines/bladerunner/scene.cpp
@@ -27,9 +27,9 @@
#include "bladerunner/actor.h"
#include "bladerunner/chapters.h"
#include "bladerunner/gameinfo.h"
+#include "bladerunner/scene_objects.h"
#include "bladerunner/script/script.h"
#include "bladerunner/slice_renderer.h"
-#include "bladerunner/scene_objects.h"
#include "common/str.h"
#include "common/stream.h"
@@ -40,7 +40,7 @@ bool Scene::open(int setId, int sceneId, bool isLoadingGame) {
if (!isLoadingGame) {
// flush ADQ
}
- // reset mouse button status
+
_setId = setId;
_sceneId = sceneId;
@@ -51,11 +51,15 @@ bool Scene::open(int setId, int sceneId, bool isLoadingGame) {
} else {
_regions->clear();
_exits->clear();
- // reset aesc
+ // TODO: Reset aesc
+ // TODO: Clear regions
// TODO: Destroy all overlays
- _defaultLoop = 0;
- _frame = -1;
- //_loopStartSpecial = -1;
+ _defaultLoop = 0;
+ _defaultLoopSet = 0;
+ _field_20_loop_stuff = 0;
+ _specialLoopMode = -1;
+ _specialLoop = -1;
+ _frame = -1;
}
Common::String vqaName;
@@ -80,26 +84,26 @@ bool Scene::open(int setId, int sceneId, bool isLoadingGame) {
if (!_set->open(setResourceName))
return false;
- _vm->_sliceRenderer->setView(_vm->_view);
+ _vm->_sliceRenderer->setView(*_vm->_view);
if (isLoadingGame) {
- // resume()
- if (sceneId >= 73 && sceneId <= 76) {
- _vm->_script->SceneLoaded();
- return true;
- }
+ // TODO: Advance VQA frame
+ if (sceneId >= 73 && sceneId <= 76)
+ _vm->_script->InitializeScene();
+ return true;
}
// TODO: set VQADecoder parameters
// TODO: Set actor position from scene info
- //advance frame 0
- _vm->_playerActor->set_at_xyz(_actorStartPosition, _actorStartFacing, false, 0, 0);
+ _vm->_playerActor->setAtXYZ(_actorStartPosition, _actorStartFacing);
+
// TODO: Set actor set
+
_vm->_script->SceneLoaded();
_vm->_sceneObjects->clear();
-
+
// Init click map
int actorCount = _vm->_gameInfo->getActorCount();
for (int i = 0; i != actorCount; ++i) {
@@ -115,15 +119,15 @@ bool Scene::open(int setId, int sceneId, bool isLoadingGame) {
actor->isRetired());
}
}
-
+
_set->addObjectsToScene(_vm->_sceneObjects);
- //add all items to scene
- //calculate walking obstacles??
+ // TODO: add all items to scene
+ // TODO: calculate walking obstacles??
+
+ // if (_playerWalkedIn) { // TODO: Not _playerWalkedIn
+ // _vm->_script->PlayerWalkedIn();
+ // }
- if (_playerWalkedIn) {
- //_vm->_script->PlayerWalkedIn();
- }
-
return true;
}
@@ -132,9 +136,23 @@ 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();
+ }
- memcpy(surface.getPixels(), _vqaPlayer.getZBuffer(), 640 * 480 * 2);
+ if (frame < 0) {
+ return frame;
}
+ _frame = frame;
+
+ if (_specialLoopMode == 0 && frame == _vqaPlayer.getLoopEndFrame(_specialLoop)) {
+ _playerWalkedIn = true;
+ _specialLoopMode = -1;
+ }
+ if (_specialLoopMode == 0 && !_defaultLoopSet) {
+ _vqaPlayer.setLoop(_defaultLoop + 1);
+ _defaultLoopSet = true;
+ }
+
return frame;
}
@@ -143,17 +161,29 @@ void Scene::setActorStart(Vector3 position, int facing) {
_actorStartFacing = facing;
}
-
-int Scene::getSetId() {
- return _setId;
+void Scene::loopSetDefault(int a) {
+ // warning("\t\t\tScene::loopSetDefault(%d)", a);
+ _defaultLoop = a;
}
+void Scene::loopStartSpecial(int a, int b, int c) {
+ // warning("\t\t\tScene::loopStartSpecial(%d, %d, %d)", a, b, c);
+ _specialLoopMode = a;
+ _specialLoop = b;
-int Scene::getSceneId() {
- return _sceneId;
+ if (_specialLoop == 1) {
+ // a1->on_loop_end_switch_to_set_id = sub_42BE08_options_get_set_enter_arg_1(&unk_48E910_options);
+ // a1->on_loop_end_switch_to_scene_id = sub_42BE00_options_get_set_enter_arg_2(&unk_48E910_options);
+ }
+
+ if (c) {
+ // _field_20_loop_stuff = 1;
+ // v6 = a1->_field_28_loop_special_loop_number;
+ // sub_453434_scene_method_loop(a1);
+ }
}
-int Scene::findObject(char* objectName) {
+int Scene::findObject(const char *objectName) {
return _set->findObject(objectName);
}
@@ -184,7 +214,7 @@ void Scene::objectSetIsObstacle(int objectId, bool isObstacle, bool sceneLoaded,
void Scene::objectSetIsObstacleAll(bool isObstacle, bool sceneLoaded) {
int i;
- for (i = 0; i < (int)_set->_objectCount; i++) {
+ for (i = 0; i < (int)_set->getObjectCount(); i++) {
_set->objectSetIsObstacle(i, isObstacle);
if (sceneLoaded) {
_vm->_sceneObjects->setIsObstacle(i + 198, isObstacle);
@@ -192,11 +222,15 @@ void Scene::objectSetIsObstacleAll(bool isObstacle, bool sceneLoaded) {
}
}
-void Scene::objectSetIsCombatTarget(int objectId, bool isCombatTarget, bool sceneLoaded) {
- _set->objectSetIsCombatTarget(objectId, isCombatTarget);
+void Scene::objectSetIsTarget(int objectId, bool isTarget, bool sceneLoaded) {
+ _set->objectSetIsTarget(objectId, isTarget);
if (sceneLoaded) {
- _vm->_sceneObjects->setIsCombatTarget(objectId + 198, isCombatTarget);
+ _vm->_sceneObjects->setIsTarget(objectId + 198, isTarget);
}
}
+const char *Scene::objectGetName(int objectId) {
+ return _set->objectGetName(objectId);
+}
+
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/scene.h b/engines/bladerunner/scene.h
index cabd912b0d..1a3c9f38bf 100644
--- a/engines/bladerunner/scene.h
+++ b/engines/bladerunner/scene.h
@@ -25,10 +25,10 @@
#include "bladerunner/bladerunner.h"
+#include "bladerunner/regions.h"
#include "bladerunner/set.h"
-//#include "bladerunner/view.h"
+#include "bladerunner/view.h"
#include "bladerunner/vqa_player.h"
-#include "bladerunner/regions.h"
namespace BladeRunner {
@@ -42,27 +42,41 @@ public:
int _setId;
int _sceneId;
VQAPlayer _vqaPlayer;
+
int _defaultLoop;
+ int _defaultLoopSet;
+ int _field_20_loop_stuff;
+ int _specialLoopMode;
+ int _specialLoop;
+ int _introFinished;
int _nextSetId;
int _nextSceneId;
int _frame;
+
Vector3 _actorStartPosition;
int _actorStartFacing;
bool _playerWalkedIn;
+ View _view;
+
Regions* _regions;
Regions* _exits;
+ // _default_loop_id = 0;
+ // _scene_vqa_frame_number = -1;
+
+
public:
Scene(BladeRunnerEngine *vm)
: _vm(vm),
_set(new Set(vm)),
_setId(-1),
_sceneId(-1),
- _vqaPlayer(vm, vm->_view),
+ _vqaPlayer(vm),
_defaultLoop(0),
_nextSetId(-1),
_nextSceneId(-1),
_playerWalkedIn(false),
+ _introFinished(false),
_regions(new Regions()),
_exits(new Regions())
{}
@@ -76,15 +90,23 @@ public:
bool open(int setId, int sceneId, bool isLoadingGame);
int advanceFrame(Graphics::Surface &surface, uint16 *&zBuffer);
void setActorStart(Vector3 position, int facing);
- int getSetId();
- int getSceneId();
- int findObject(char *objectName);
+
+ void loopSetDefault(int a);
+ void loopStartSpecial(int a, int b, int c);
+
+ int getSetId() { return _setId; }
+ int getSceneId() { return _sceneId; }
+
+ bool didPlayerWalkIn() { bool r = _playerWalkedIn; _playerWalkedIn = false; return r; }
+
+ int findObject(const char *objectName);
bool objectSetHotMouse(int objectId);
bool objectGetBoundingBox(int objectId, BoundingBox *boundingBox);
void objectSetIsClickable(int objectId, bool isClickable, bool sceneLoaded);
void objectSetIsObstacle(int objectId, bool isObstacle, bool sceneLoaded, bool updateWalkpath);
void objectSetIsObstacleAll(bool isObstacle, bool sceneLoaded);
- void objectSetIsCombatTarget(int objectId, bool isCombatTarget, bool sceneLoaded);
+ void objectSetIsTarget(int objectId, bool isTarget, bool sceneLoaded);
+ const char *objectGetName(int objectId);
};
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/scene_objects.cpp b/engines/bladerunner/scene_objects.cpp
index ec9e247fd2..ba09edf477 100644
--- a/engines/bladerunner/scene_objects.cpp
+++ b/engines/bladerunner/scene_objects.cpp
@@ -1,5 +1,29 @@
+/* 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/scene_objects.h"
+#include "bladerunner/view.h"
+
namespace BladeRunner {
SceneObjects::SceneObjects(BladeRunnerEngine *vm, View *view) {
@@ -10,8 +34,7 @@ SceneObjects::SceneObjects(BladeRunnerEngine *vm, View *view) {
_sceneObjects = new SceneObject[SCENE_OBJECTS_COUNT];
_sceneObjectsSortedByDistance = new int[SCENE_OBJECTS_COUNT];
- int i;
- for (i = 0; i < SCENE_OBJECTS_COUNT; i++) {
+ for (int i = 0; i < SCENE_OBJECTS_COUNT; ++i) {
_sceneObjectsSortedByDistance[i] = -1;
}
}
@@ -25,10 +48,8 @@ SceneObjects::~SceneObjects() {
delete[] _sceneObjects;
}
-
void SceneObjects::clear() {
- int i;
- for (i = 0; i < SCENE_OBJECTS_COUNT; i++) {
+ for (int i = 0; i < SCENE_OBJECTS_COUNT; ++i) {
_sceneObjects[i]._sceneObjectId = -1;
_sceneObjects[i]._sceneObjectType = SceneObjectTypeUnknown;
_sceneObjects[i]._distanceToCamera = 0;
@@ -36,39 +57,39 @@ void SceneObjects::clear() {
_sceneObjects[i]._isClickable = 0;
_sceneObjects[i]._isObstacle = 0;
_sceneObjects[i]._unknown1 = 0;
- _sceneObjects[i]._isCombatTarget = 0;
+ _sceneObjects[i]._isTarget = 0;
_sceneObjects[i]._isMoving = 0;
_sceneObjects[i]._isRetired = 0;
}
}
-bool SceneObjects::addActor(int sceneObjectId, BoundingBox* boundingBox, Common::Rect* screenRectangle, uint8 isClickable, uint8 isMoving, uint8 isCombatTarget, uint8 isRetired) {
- return addSceneObject(sceneObjectId, SceneObjectTypeActor, boundingBox, screenRectangle, isClickable, 0, 0, isCombatTarget, isMoving, isRetired);
+bool SceneObjects::addActor(int sceneObjectId, BoundingBox* boundingBox, Common::Rect* screenRectangle, uint8 isClickable, uint8 isMoving, uint8 isTarget, uint8 isRetired) {
+ return addSceneObject(sceneObjectId, SceneObjectTypeActor, boundingBox, screenRectangle, isClickable, 0, 0, isTarget, isMoving, isRetired);
}
-bool SceneObjects::addObject(int sceneObjectId, BoundingBox* boundingBox, uint8 isClickable, uint8 isObstacle, uint8 unknown1, uint8 isCombatTarget) {
+bool SceneObjects::addObject(int sceneObjectId, BoundingBox* boundingBox, uint8 isClickable, uint8 isObstacle, uint8 unknown1, uint8 isTarget) {
Common::Rect rect(-1, -1, -1, -1);
- return addSceneObject(sceneObjectId, SceneObjectTypeObject, boundingBox, &rect, isClickable, isObstacle, unknown1, isCombatTarget, 0, 0);
+ return addSceneObject(sceneObjectId, SceneObjectTypeObject, boundingBox, &rect, isClickable, isObstacle, unknown1, isTarget, 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::addItem(int sceneObjectId, BoundingBox* boundingBox, Common::Rect* screenRectangle, uint8 isTarget, uint8 isObstacle) {
+ return addSceneObject(sceneObjectId, SceneObjectTypeItem, boundingBox, screenRectangle, isObstacle, 0, 0, isTarget, 0, 0);
}
bool SceneObjects::remove(int sceneObjectId)
{
int i = findById(sceneObjectId);
- if (i == -1 || !_sceneObjects[i]._present) {
+ if (i == -1) {
return false;
}
+
int j;
- for (j = 0; j < _count; j++) {
+ for (j = 0; j < _count; ++j) {
if (_sceneObjectsSortedByDistance[j] == i) {
break;
}
}
- int k;
- for (k = j; k < _count - 1; k++) {
+ for (int k = j; k < _count - 1; ++k) {
_sceneObjectsSortedByDistance[k] = _sceneObjectsSortedByDistance[k + 1];
}
@@ -76,36 +97,33 @@ bool SceneObjects::remove(int sceneObjectId)
return true;
}
-int SceneObjects::findByXYZ(int *isClickable, int *isObstacle, int *isCombatTarget, float x, float y, float z, int mustBeClickable, int mustBeObstacle, int mustBeCombatTarget) {
- BoundingBox boundingBox;
+int SceneObjects::findByXYZ(int *isClickable, int *isObstacle, int *isTarget, float x, float y, float z, int findClickables, int findObstacles, int findTargets) {
*isClickable = 0;
- *isObstacle = 0;
- *isCombatTarget = 0;
+ *isObstacle = 0;
+ *isTarget = 0;
- if (!_count)
- return -1;
+ for (int i = 0; i < _count; ++i) {
+ assert(_sceneObjectsSortedByDistance[i] < _count);
- int i;
- for (i = 0; i < _count; i++) {
- //assert(_sceneObjectsSortedByDistance[i] < _count);
- SceneObject *sceneObject = &_sceneObjects[_sceneObjectsSortedByDistance[i]];
- if ((mustBeClickable && !sceneObject->_isClickable)
- || (mustBeObstacle && !sceneObject->_isObstacle)
- || (mustBeCombatTarget && !sceneObject->_isCombatTarget)) {
- continue;
- }
+ SceneObject &sceneObject = _sceneObjects[_sceneObjectsSortedByDistance[i]];
- boundingBox = sceneObject->_boundingBox;
+ if ((findClickables && sceneObject._isClickable) ||
+ (findObstacles && sceneObject._isObstacle) ||
+ (findTargets && sceneObject._isTarget))
+ {
+ BoundingBox 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 (sceneObject._sceneObjectType == SceneObjectTypeObject || sceneObject._sceneObjectType == SceneObjectTypeItem) {
+ boundingBox.expand(-4.0, 0.0, -4.0, 4.0, 0.0, 4.0);
+ }
+
+ if (boundingBox.inside(x, y, z)) {
+ *isClickable = sceneObject._isClickable;
+ *isObstacle = sceneObject._isObstacle;
+ *isTarget = sceneObject._isTarget;
- if (boundingBox.inside(x, y, z)) {
- *isClickable = sceneObject->_isClickable;
- *isObstacle = sceneObject->_isObstacle;
- *isCombatTarget = sceneObject->_isCombatTarget;
- return sceneObject->_sceneObjectId;
+ return sceneObject._sceneObjectId;
+ }
}
}
@@ -114,8 +132,7 @@ int SceneObjects::findByXYZ(int *isClickable, int *isObstacle, int *isCombatTarg
int SceneObjects::findById(int sceneObjectId)
{
- int i;
- for (i = 0; i < _count; i++) {
+ for (int i = 0; i < _count; ++i) {
if (_sceneObjects[i]._present && _sceneObjects[i]._sceneObjectId == sceneObjectId) {
return i;
}
@@ -123,23 +140,23 @@ int SceneObjects::findById(int sceneObjectId)
return -1;
}
-bool SceneObjects::addSceneObject(int sceneObjectId, SceneObjectType sceneObjectType, BoundingBox* boundingBox, Common::Rect* screenRectangle, uint8 isClickable, uint8 isObstacle, uint8 unknown1, uint8 isCombatTarget, uint isMoving, uint isRetired) {
+bool SceneObjects::addSceneObject(int sceneObjectId, SceneObjectType sceneObjectType, BoundingBox* boundingBox, Common::Rect* screenRectangle, uint8 isClickable, uint8 isObstacle, uint8 unknown1, uint8 isTarget, uint isMoving, uint isRetired) {
int index = findEmpty();
- if (_count >= SCENE_OBJECTS_COUNT || index == -1) {
+ if (index == -1) {
return false;
}
- _sceneObjects[index]._sceneObjectId = sceneObjectId;
+ _sceneObjects[index]._sceneObjectId = sceneObjectId;
_sceneObjects[index]._sceneObjectType = sceneObjectType;
- _sceneObjects[index]._present = 1;
- _sceneObjects[index]._boundingBox = *boundingBox;
+ _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]._isMoving = isMoving;
- _sceneObjects[index]._isRetired = isRetired;
+ _sceneObjects[index]._isClickable = isClickable;
+ _sceneObjects[index]._isObstacle = isObstacle;
+ _sceneObjects[index]._unknown1 = unknown1;
+ _sceneObjects[index]._isTarget = isTarget;
+ _sceneObjects[index]._isMoving = isMoving;
+ _sceneObjects[index]._isRetired = isRetired;
float centerZ = (_sceneObjects[index]._boundingBox.getZ0() + _sceneObjects[index]._boundingBox.getZ1()) / 2.0;
@@ -147,14 +164,13 @@ bool SceneObjects::addSceneObject(int sceneObjectId, SceneObjectType sceneObject
_sceneObjects[index]._distanceToCamera = distanceToCamera;
// insert according to distance from camera
- int i, j;
- for (i = 0; i < _count; i++) {
+ int i;
+ for (i = 0; i < _count; ++i) {
if (distanceToCamera < _sceneObjects[_sceneObjectsSortedByDistance[i]]._distanceToCamera) {
break;
}
}
-
- for (j = _count - 1; j >= i; j--) {
+ for (int j = _count - 1; j >= i; --j) {
_sceneObjectsSortedByDistance[j + 1] = _sceneObjectsSortedByDistance[j];
}
@@ -164,9 +180,7 @@ bool SceneObjects::addSceneObject(int sceneObjectId, SceneObjectType sceneObject
}
int SceneObjects::findEmpty() {
- int i;
- for (i = 0; i < SCENE_OBJECTS_COUNT; i++)
- {
+ for (int i = 0; i < SCENE_OBJECTS_COUNT; ++i) {
if (!_sceneObjects[i]._present)
return i;
}
@@ -175,7 +189,7 @@ int SceneObjects::findEmpty() {
void SceneObjects::setMoving(int sceneObjectId, bool isMoving) {
int i = findById(sceneObjectId);
- if (i == -1 || !_sceneObjects[i]._present) {
+ if (i == -1) {
return;
}
_sceneObjects[i]._isMoving = isMoving;
@@ -183,7 +197,7 @@ void SceneObjects::setMoving(int sceneObjectId, bool isMoving) {
void SceneObjects::setRetired(int sceneObjectId, bool isRetired) {
int i = findById(sceneObjectId);
- if (i == -1 || !_sceneObjects[i]._present) {
+ if (i == -1) {
return;
}
_sceneObjects[i]._isRetired = isRetired;
@@ -191,12 +205,12 @@ void SceneObjects::setRetired(int sceneObjectId, bool isRetired) {
bool SceneObjects::isBetweenTwoXZ(int sceneObjectId, float x1, float z1, float x2, float z2) {
int i = findById(sceneObjectId);
- if (i == -1 || !_sceneObjects[i]._present) {
+ if (i == -1) {
return false;
}
float objectX1, objectY1, objectZ1, objectX2, objectY2, objectZ2;
- _sceneObjects[i]._boundingBox.getXyz(&objectX1, &objectY1, &objectZ1, &objectX2, &objectY2, &objectZ2);
+ _sceneObjects[i]._boundingBox.getXYZ(&objectX1, &objectY1, &objectZ1, &objectX2, &objectY2, &objectZ2);
//TODO
// if (!lineIntersectection(sourceX, sourceZ, targetX, targetZ, objectX1, objectZ1, objectX2, objectZ1, &intersectionX, &intersectionY, &v18)
@@ -210,7 +224,7 @@ bool SceneObjects::isBetweenTwoXZ(int sceneObjectId, float x1, float z1, float x
void SceneObjects::setIsClickable(int sceneObjectId, bool isClickable) {
int i = findById(sceneObjectId);
- if (i == -1 || !_sceneObjects[i]._present) {
+ if (i == -1) {
return;
}
_sceneObjects[i]._isClickable = isClickable;
@@ -218,18 +232,18 @@ void SceneObjects::setIsClickable(int sceneObjectId, bool isClickable) {
void SceneObjects::setIsObstacle(int sceneObjectId, bool isObstacle) {
int i = findById(sceneObjectId);
- if (i == -1 || !_sceneObjects[i]._present) {
+ if (i == -1) {
return;
}
_sceneObjects[i]._isObstacle = isObstacle;
}
-void SceneObjects::setIsCombatTarget(int sceneObjectId, bool isCombatTarget) {
+void SceneObjects::setIsTarget(int sceneObjectId, bool isTarget) {
int i = findById(sceneObjectId);
- if (i == -1 || !_sceneObjects[i]._present) {
+ if (i == -1) {
return;
}
- _sceneObjects[i]._isCombatTarget = isCombatTarget;
+ _sceneObjects[i]._isTarget = isTarget;
}
@@ -237,4 +251,4 @@ void SceneObjects::updateWalkpath() {
//TODO: implement
}
-}
+} // End of namespace BladeRunner
diff --git a/engines/bladerunner/scene_objects.h b/engines/bladerunner/scene_objects.h
index bccb2ea376..047301d880 100644
--- a/engines/bladerunner/scene_objects.h
+++ b/engines/bladerunner/scene_objects.h
@@ -23,76 +23,76 @@
#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;
- enum SceneObjectType
- {
- SceneObjectTypeUnknown = -1,
- SceneObjectTypeActor = 0,
- SceneObjectTypeObject = 1,
- SceneObjectTypeItem = 2,
- };
+class BladeRunnerEngine;
+class View;
+
+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
- struct SceneObject
- {
- int _sceneObjectId;
- SceneObjectType _sceneObjectType;
- BoundingBox _boundingBox;
- Common::Rect _screenRectangle;
- float _distanceToCamera;
- int _present;
- int _isClickable;
- int _isObstacle;
- int _unknown1;
- int _isCombatTarget;
- int _isMoving;
- int _isRetired;
- };
+struct SceneObject
+{
+ int _sceneObjectId;
+ SceneObjectType _sceneObjectType;
+ BoundingBox _boundingBox;
+ Common::Rect _screenRectangle;
+ float _distanceToCamera;
+ int _present;
+ int _isClickable;
+ int _isObstacle;
+ int _unknown1;
+ int _isTarget;
+ int _isMoving;
+ int _isRetired;
+};
+
+class SceneObjects {
+ BladeRunnerEngine *_vm;
+private:
+ View *_view;
+ int _count;
+ SceneObject *_sceneObjects;
+ int *_sceneObjectsSortedByDistance;
- class SceneObjects {
- BladeRunnerEngine *_vm;
- private:
- View *_view;
- int _count;
- SceneObject *_sceneObjects;
- int *_sceneObjectsSortedByDistance;
+public:
+ SceneObjects(BladeRunnerEngine *vm, View *view);
+ ~SceneObjects();
+ bool addActor(int sceneObjectId, BoundingBox *boundingBox, Common::Rect *screenRectangle, uint8 isClickable, uint8 unknown1, uint8 isTarget, uint8 isRetired);
+ bool addObject(int sceneObjectId, BoundingBox *boundingBox, uint8 isClickable, uint8 isObstacle, uint8 unknown1, uint8 isTarget);
+ bool addItem(int sceneObjectId, BoundingBox *boundingBox, Common::Rect *screenRectangle, uint8 isTarget, uint8 isObstacle);
+ bool remove(int sceneObjectId);
+ void clear();
+ int findByXYZ(int *isClickable, int *isObstacle, int *isTarget, float x, float y, float z, int findClickables, int findObstacles, int findTargets);
+ void setMoving(int sceneObjectId, bool isMoving);
+ void setRetired(int sceneObjectId, bool isRetired);
+ bool isBetweenTwoXZ(int sceneObjectId, float x1, float z1, float x2, float z2);
+ void setIsClickable(int sceneObjectId, bool isClickable);
+ void setIsObstacle(int sceneObjectId, bool isObstacle);
+ void setIsTarget(int sceneObjectId, bool isTarget);
+ void updateWalkpath();
- public:
- SceneObjects(BladeRunnerEngine *vm, View *view);
- ~SceneObjects();
- 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);
- void clear();
- int findByXYZ(int *isClickable, int *isObstacle, int *isCombatTarget, float x, float y, float z, int mustBeClickable, int mustBeObstacle, int mustBeCombatTarget);
- void setMoving(int sceneObjectId, bool isMoving);
- void setRetired(int sceneObjectId, bool isRetired);
- bool isBetweenTwoXZ(int sceneObjectId, float x1, float z1, float x2, float z2);
- void setIsClickable(int sceneObjectId, bool isClickable);
- void setIsObstacle(int sceneObjectId, bool isObstacle);
- void setIsCombatTarget(int sceneObjectId, bool isCombatTarget);
- void updateWalkpath();
- 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();
- };
+private:
+ int findById(int sceneObjectId);
+ bool addSceneObject(int sceneObjectId, SceneObjectType sceneObjectType, BoundingBox *boundingBox, Common::Rect *screenRectangle, uint8 isClickable, uint8 isObstacle, uint8 unknown1, uint8 isTarget, uint unknown2, uint isRetired);
+ int findEmpty();
+};
+} // End of namespace BladeRunner
-}
#endif
diff --git a/engines/bladerunner/script/ai_00_mccoy.cpp b/engines/bladerunner/script/ai_00_mccoy.cpp
new file mode 100644
index 0000000000..2d722f1c8b
--- /dev/null
+++ b/engines/bladerunner/script/ai_00_mccoy.cpp
@@ -0,0 +1,174 @@
+/* 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/script/ai_00_mccoy.h"
+
+namespace BladeRunner {
+
+AIScript_McCoy::AIScript_McCoy(BladeRunnerEngine *vm)
+ : AIScriptBase(vm)
+{}
+
+void AIScript_McCoy::Initialize()
+{
+ dword_45A0D0_animation_state = 0;
+ dword_45A0D4 = 0;
+ dword_45A0D8 = 0;
+ dword_45A0DC = 30;
+ dword_45A0E0 = 1;
+ dword_45A0E4 = 0;
+ dword_45A0E8 = 3;
+}
+
+void AIScript_McCoy::UpdateAnimation(int *animation, int *frame)
+{
+ *animation = *frame = 0;
+ switch (dword_45A0D0_animation_state)
+ {
+ case 0:
+ *animation = 19;
+ if (dword_45A0D8 < dword_45A0DC)
+ {
+ *frame = dword_45A0E8;
+ dword_45A0D4 += dword_45A0E0;
+ if (dword_45A0D4 > dword_45A0E8)
+ {
+ dword_45A0D4 = dword_45A0E8;
+ dword_45A0E0 = -1;
+ }
+ else
+ {
+ *frame = dword_45A0D4;
+ if (dword_45A0D4 < dword_45A0E4)
+ {
+ dword_45A0D4 = dword_45A0E4;
+ dword_45A0E0 = 1;
+ *frame = dword_45A0E4;
+ }
+ }
+ dword_45A0D8++;
+ }
+ else
+ {
+ dword_45A0D4 += dword_45A0E0;
+ dword_45A0DC = 0;
+ if (dword_45A0D4 == 18 && Random_Query(0, 2))
+ {
+ dword_45A0E0 = -1;
+ dword_45A0D8 = 0;
+ dword_45A0E4 = 14;
+ dword_45A0E8 = 18;
+ dword_45A0DC = Random_Query(0, 30);
+ }
+ if (dword_45A0D4 == 26)
+ {
+ if (Random_Query(0, 2))
+ {
+ dword_45A0E0 = -1;
+ dword_45A0D8 = 0;
+ dword_45A0E4 = 23;
+ dword_45A0E8 = 26;
+ dword_45A0DC = Random_Query(0, 30);
+ }
+ }
+ if (dword_45A0D4 >= Slice_Animation_Query_Number_Of_Frames(19))
+ {
+ dword_45A0D4 = 0;
+ if (Random_Query(0, 2))
+ {
+ dword_45A0D8 = 0;
+ dword_45A0E4 = 0;
+ dword_45A0E8 = 3;
+ dword_45A0DC = Random_Query(0, 45);
+ }
+ }
+ *frame = dword_45A0D4;
+ if (dword_45A0D4 < 0)
+ {
+ *frame = Slice_Animation_Query_Number_Of_Frames(19) - 1;
+ dword_45A0D4 = *frame;
+ }
+ }
+ break;
+
+ // Continue walking (follows state 32)
+ case 30:
+ *animation = 13;
+ if (++dword_45A0D4 >= Slice_Animation_Query_Number_Of_Frames(13))
+ dword_45A0D4 = 0;
+ *frame = dword_45A0D4;
+
+ if (dword_45A0D4 == 2)
+ ; //Sound_Right_Footstep_Walk(0);
+ else if (dword_45A0D4 == 10)
+ ; //Sound_Left_Footstep_Walk(0);
+
+ break;
+
+ // Start walking
+ case 32:
+ dword_45A0D4 = 1;
+ dword_45A0D0_animation_state = 30;
+ *animation = 13;
+ *frame = 1;
+ break;
+
+ case 58:
+ *animation = 47;
+ if (dword_45A0D4++ == 5) {
+ int stepSound;
+ switch (Random_Query(0, 2)) {
+ case 0:
+ stepSound = 595;
+ break;
+ case 1:
+ stepSound = 594;
+ break;
+ default:
+ stepSound = 593;
+ }
+ (void)stepSound;
+ // Ambient_Sounds_Play_Sound(stepSound, 39, 0, 0, 99);
+ }
+ if (dword_45A0D4 > Slice_Animation_Query_Number_Of_Frames(*animation) - 2)
+ dword_45A0D4 = 0;
+ *frame = dword_45A0D4;
+ break;
+ }
+}
+
+void AIScript_McCoy::ChangeAnimationMode(int mode)
+{
+ switch (mode)
+ {
+ case 0:
+ dword_45A0D0_animation_state = 0;
+ dword_45A0D4 = 0;
+ break;
+
+ case 1:
+ dword_45A0D0_animation_state = 32;
+ break;
+ }
+}
+
+} // End of namespace BladeRunner
diff --git a/engines/bladerunner/script/ai_00_mccoy.h b/engines/bladerunner/script/ai_00_mccoy.h
new file mode 100644
index 0000000000..11c9f1d8cb
--- /dev/null
+++ b/engines/bladerunner/script/ai_00_mccoy.h
@@ -0,0 +1,45 @@
+/* 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/script/script.h"
+
+#include "bladerunner/bladerunner.h"
+
+namespace BladeRunner {
+
+class AIScript_McCoy : public AIScriptBase {
+ int dword_45A0D0_animation_state;
+ int dword_45A0D4;
+ int dword_45A0D8;
+ int dword_45A0DC;
+ int dword_45A0E0;
+ int dword_45A0E4;
+ int dword_45A0E8;
+public:
+ AIScript_McCoy(BladeRunnerEngine *vm);
+
+ void Initialize();
+ void UpdateAnimation(int *animation, int *frame);
+ void ChangeAnimationMode(int mode);
+};
+
+} // End of namespace BladeRunner
diff --git a/engines/bladerunner/script/aiscript_officer_leroy.cpp b/engines/bladerunner/script/aiscript_officer_leroy.cpp
new file mode 100644
index 0000000000..1acb096b01
--- /dev/null
+++ b/engines/bladerunner/script/aiscript_officer_leroy.cpp
@@ -0,0 +1,87 @@
+/* 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/script/aiscript_officer_leroy.h"
+
+namespace BladeRunner {
+
+AIScript_Officer_Leroy::AIScript_Officer_Leroy(BladeRunnerEngine *vm)
+ : AIScriptBase(vm)
+{}
+
+void AIScript_Officer_Leroy::Initialize()
+{
+ var_45D5B0_animation_state = 0;
+ var_45D5B4_frame = 0;
+ var_45D5B8 = 0;
+
+ Actor_Put_In_Set(23, 69);
+ Actor_Set_At_XYZ(23, -261.80f, 6.00f, 79.58f, 512);
+ // Actor_Set_Goal_Number(23, 0);
+ // Actor_Set_Frame_Rate_FPS(23, 8);
+}
+
+void AIScript_Officer_Leroy::UpdateAnimation(int *animation, int *frame)
+{
+ if (var_45D5B8 == 0) {
+ *animation = 589;
+ var_45D5B4_frame++;
+
+ if (var_45D5B4_frame >= Slice_Animation_Query_Number_Of_Frames(589))
+ {
+ var_45D5B4_frame = 0;
+ var_45D5B8 = Random_Query(0, 2);
+ }
+ } else if (var_45D5B8 == 1) {
+ *animation = 590;
+ var_45D5B4_frame++;
+
+ if (var_45D5B4_frame >= Slice_Animation_Query_Number_Of_Frames(590))
+ {
+ var_45D5B4_frame = 0;
+ var_45D5B8 = Random_Query(0, 2);
+ }
+ } else if (var_45D5B8 == 2) {
+ *animation = 591;
+ var_45D5B4_frame++;
+
+ if (var_45D5B4_frame >= Slice_Animation_Query_Number_Of_Frames(591))
+ {
+ var_45D5B4_frame = 0;
+ var_45D5B8 = Random_Query(0, 2);
+ }
+ }
+
+ *frame = var_45D5B4_frame;
+}
+
+void AIScript_Officer_Leroy::ChangeAnimationMode(int mode)
+{
+ switch (mode)
+ {
+ case 1:
+ var_45D5B0_animation_state = 32;
+ break;
+ }
+}
+
+} // End of namespace BladeRunner
diff --git a/engines/bladerunner/script/aiscript_officer_leroy.h b/engines/bladerunner/script/aiscript_officer_leroy.h
new file mode 100644
index 0000000000..7d81b625e9
--- /dev/null
+++ b/engines/bladerunner/script/aiscript_officer_leroy.h
@@ -0,0 +1,41 @@
+/* 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/script/script.h"
+
+#include "bladerunner/bladerunner.h"
+
+namespace BladeRunner {
+
+class AIScript_Officer_Leroy : public AIScriptBase {
+ int var_45D5B0_animation_state;
+ int var_45D5B4_frame;
+ int var_45D5B8;
+public:
+ AIScript_Officer_Leroy(BladeRunnerEngine *vm);
+
+ void Initialize();
+ void UpdateAnimation(int *animation, int *frame);
+ void ChangeAnimationMode(int mode);
+};
+
+} // End of namespace BladeRunner
diff --git a/engines/bladerunner/script/rc01.cpp b/engines/bladerunner/script/rc01.cpp
index 73a5f899ac..fa1e42de2e 100644
--- a/engines/bladerunner/script/rc01.cpp
+++ b/engines/bladerunner/script/rc01.cpp
@@ -26,9 +26,12 @@
#include "bladerunner/audio_player.h"
#include "bladerunner/bladerunner.h"
+#include "common/debug.h"
+
namespace BladeRunner {
void ScriptRC01::InitializeScene() {
+ // Game_Flag_Set(24);
if (!Game_Flag_Query(24)) {
Ambient_Sounds_Remove_All_Non_Looping_Sounds(1);
Ambient_Sounds_Remove_All_Looping_Sounds(1);
@@ -38,7 +41,7 @@ void ScriptRC01::InitializeScene() {
Outtake_Play(33, 1); // DSCENT_E.VQA
}
- Game_Flag_Set(9); // Force flag 9 so McCoy will be in view
+ // Game_Flag_Set(9); // Force flag 9 so McCoy will be in view
if (Game_Flag_Query(9)) {
Setup_Scene_Information(-171.16, 5.55, 27.28, 616);
} else if (Game_Flag_Query(114)) {
@@ -46,6 +49,7 @@ void ScriptRC01::InitializeScene() {
} else {
Setup_Scene_Information( -10.98, -0.30, 318.15, 616);
}
+ // Setup_Scene_Information(-151.98, -0.30, 318.15, 616);
Scene_Exit_Add_2D_Exit(0, 314, 145, 340, 255, 0);
if (Game_Flag_Query(249))
@@ -118,7 +122,67 @@ void ScriptRC01::InitializeScene() {
}
void ScriptRC01::SceneLoaded() {
- if (!Game_Flag_Query(24)){
+ Obstacle_Object("HYDRANT02", 1);
+ Obstacle_Object("PARKING METER 04", 1);
+ Obstacle_Object("CHEVY PROP", 1);
+ Obstacle_Object("PARKING METER 01", 1);
+ Obstacle_Object("T-CAN01", 1);
+ Obstacle_Object("BARICADE01", 1);
+ Obstacle_Object("BARICADE02", 1);
+ Obstacle_Object("DOOR LEFT", 1);
+ Unobstacle_Object("BOX06", 1);
+ Clickable_Object("DOORWAY01");
+ Clickable_Object("DOOR LEFT");
+ Clickable_Object("HYDRANT02");
+ Clickable_Object("T-CAN01");
+ Clickable_Object("BARICADE01");
+ Clickable_Object("70_1");
+ Clickable_Object("70_2");
+ Clickable_Object("70_3");
+ Clickable_Object("70_5");
+ Clickable_Object("70_6");
+ Unclickable_Object("BARICADE02");
+ Unclickable_Object("BARICADE05");
+ Unclickable_Object("SPINNER BODY");
+ Unclickable_Object("HORSE01");
+ Unclickable_Object("DOORWAY01");
+ Unobstacle_Object("DOORWAY01", 1);
+
+ if (Game_Flag_Query(186)) {
+ Unclickable_Object("70_1");
+ Unclickable_Object("70_2");
+ Unclickable_Object("70_3");
+ Unclickable_Object("70_5");
+ Unclickable_Object("70_6");
+ Unclickable_Object("BARICADE01");
+ Unclickable_Object("BARICADE03");
+ Unclickable_Object("BARICADE04");
+ Unobstacle_Object("70_1", 1);
+ Unobstacle_Object("70_2", 1);
+ Unobstacle_Object("70_3", 1);
+ Unobstacle_Object("70_5", 1);
+ Unobstacle_Object("70_6", 1);
+ Unobstacle_Object("BARICADE01", 1);
+ Unobstacle_Object("BARICADE02", 1);
+ Unobstacle_Object("BARICADE03", 1);
+ Unobstacle_Object("BARICADE04", 1);
+ Unobstacle_Object("BARICADE05", 1);
+ }
+
+ if (!Game_Flag_Query(186)) {
+ Preload(13);
+ Preload(14);
+ Preload(19);
+ Preload(582);
+ Preload(589);
+ }
+
+ /*
+ if (!Game_Flag_Query(163))
+ Item_Add_To_World(66, 938, 69, -148.60f, -0.30f, 225.15f, 256, 24, 24, 0, 1, 0, 1);
+ */
+
+ if (!Game_Flag_Query(24)) {
// ADQ_Flush();
Actor_Voice_Over(1830, 99);
Actor_Voice_Over(1850, 99);
@@ -131,6 +195,99 @@ void ScriptRC01::SceneLoaded() {
}
}
+void ScriptRC01::sub_403850()
+{
+ if (Game_Flag_Query(186))
+ return;
+
+ if (Loop_Actor_Walk_To_Scene_Object(0, "BARICADE03", 36, 1, 0))
+ return;
+
+ Actor_Set_Goal_Number(23, 0);
+ Actor_Face_Object(0, "BARICADE03", 1);
+ // Loop_Actor_Walk_To_Actor(23, 0, 36, 1, 0);
+ Actor_Face_Actor(23, 0, 1);
+ Actor_Says(0, 4500, 14);
+ I_Sez("MG: We don't want any of that abstract art oozing out onto the street.");
+ Actor_Says(23, 10, 14);
+ Actor_Set_Goal_Number(23, 1);
+}
+
+bool ScriptRC01::ClickedOn3DObject(const char *objectName) {
+ if (Object_Query_Click("BARICADE01", objectName)
+ || Object_Query_Click("BARICADE03", objectName)
+ || Object_Query_Click("BARICADE04", objectName)
+ || Object_Query_Click("70_1", objectName)
+ || Object_Query_Click("70_2", objectName)
+ || Object_Query_Click("70_3", objectName)
+ || Object_Query_Click("70_5", objectName)
+ || Object_Query_Click("70_6", objectName))
+ {
+ sub_403850();
+ return true;
+ }
+
+ if (Object_Query_Click("HYDRANT02", objectName)) {
+ if (Loop_Actor_Walk_To_Scene_Object(0, "HYDRANT02", 60, 1, 0) == 0) {
+ if (Actor_Clue_Query(0, 26)) {
+ Actor_Says(0, 6975, 3);
+ } else {
+ Actor_Face_Object(0, "HYDRANT02", 1);
+ Actor_Voice_Over(1880, 99);
+ Actor_Voice_Over(1890, 99);
+ I_Sez("JM: That McCoy--he's one funny guy! Jet-black fire truck, hehehehe...");
+ Actor_Clue_Acquire(0, 26, 1, -1);
+ }
+ }
+ return true;
+ }
+
+ if (Object_Query_Click("DOOR LEFT", objectName))
+ {
+ if (!Loop_Actor_Walk_To_Scene_Object(0, "DOOR LEFT", 48, 1, 0))
+ {
+ Actor_Face_Object(0, "DOOR LEFT", 1);
+ if (Actor_Clue_Query(0, 2) || !Actor_Query_In_Set(23, 69) || Global_Variable_Query(1) != 1)
+ {
+ Actor_Says(0, 8570, 14);
+ }
+ else
+ {
+ Actor_Set_Goal_Number(23, 0);
+ Actor_Face_Actor(23, 0, 1);
+ Actor_Says(23, 0, 12);
+ Actor_Says(0, 4495, 13);
+ Actor_Clue_Acquire(0, 2, 1, 23);
+ }
+ Actor_Clue_Acquire(0, 1, 1, -1);
+ }
+ return true;
+ }
+
+ if (Object_Query_Click("T-CAN01", objectName))
+ {
+ if (!Loop_Actor_Walk_To_Scene_Object(0, "T-CAN01", 24, 1, 0))
+ {
+ Actor_Face_Object(0, "T-CAN01", 1);
+ Actor_Voice_Over(1810, 99);
+ Actor_Voice_Over(1820, 99);
+ }
+ return true;
+ }
+
+ return false;
+}
+
+bool ScriptRC01::ClickedOn2DRegion(int region) {
+ if (region == 0) {
+ sub_403850();
+ return 1;
+ }
+
+ return 0;
+}
+
+
void ScriptRC01::SceneFrameAdvanced(int frame) {
if (frame == 1)
Sound_Play(118, 40, 0, 0, 50); // CARDOWN3.AUD
@@ -154,11 +311,41 @@ void ScriptRC01::SceneFrameAdvanced(int frame) {
Sound_Play(118, 40, 80, 80, 50); // CARDOWN3.AUD
}
-
void ScriptRC01::SceneActorChangedGoal(int actorId, int newGoal, int oldGoal, bool currentSet) {
-
}
+void ScriptRC01::PlayerWalkedIn()
+{
+ if (Game_Flag_Query(249) && !Game_Flag_Query(9) && !Game_Flag_Query(114)) {
+ // Extract to sub_4037AC():
+ Player_Loses_Control();
+ Game_Flag_Set(182);
+ Actor_Set_Immunity_To_Obstacles(0, true);
+ Loop_Actor_Walk_To_XYZ(0, -151.98, -0.30, 318.15, 0, 0, 0, 0);
+ Actor_Set_Immunity_To_Obstacles(0, false);
+ Player_Gains_Control();
+ }
+
+ if (Game_Flag_Query(114)) {
+ Player_Loses_Control();
+ Loop_Actor_Walk_To_XYZ(0, -415.98, -0.30, 262.15, 0, 0, 0, 0);
+ Player_Gains_Control();
+ Game_Flag_Reset(114);
+ }
+
+ if (Game_Flag_Query(9)) {
+ Player_Loses_Control();
+ Loop_Actor_Walk_To_XYZ(0, -203.45, 5.55, 85.05, 0, 0, 0, 0);
+ Player_Gains_Control();
+ Game_Flag_Reset(9);
+ if (Game_Flag_Query(1) && !Game_Flag_Query(4)) {
+ Actor_Voice_Over(1910, 99);
+ Actor_Voice_Over(1920, 99);
+ Actor_Voice_Over(1930, 99);
+ Game_Flag_Set(4);
+ }
+ }
+}
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/script/script.cpp b/engines/bladerunner/script/script.cpp
index c71326d75e..c93c5db4e4 100644
--- a/engines/bladerunner/script/script.cpp
+++ b/engines/bladerunner/script/script.cpp
@@ -24,21 +24,27 @@
#include "bladerunner/bladerunner.h"
+#include "bladerunner/actor.h"
+#include "bladerunner/actor_combat.h"
#include "bladerunner/ambient_sounds.h"
#include "bladerunner/audio_player.h"
#include "bladerunner/audio_speech.h"
#include "bladerunner/clues.h"
+#include "bladerunner/combat.h"
#include "bladerunner/gameflags.h"
#include "bladerunner/gameinfo.h"
+#include "bladerunner/settings.h"
+#include "bladerunner/set_effects.h"
#include "bladerunner/scene.h"
+#include "bladerunner/scene_objects.h"
+#include "bladerunner/slice_animations.h"
+#include "bladerunner/slice_renderer.h"
#include "bladerunner/text_resource.h"
#include "bladerunner/vector.h"
-#include "bladerunner/slice_renderer.h"
-#include "bladerunner/actor.h"
#include "bladerunner/waypoints.h"
-#include "bladerunner/slice_animations.h"
-#include "bladerunner/combat.h"
-#include "bladerunner/settings.h"
+
+#include "bladerunner/script/ai_00_mccoy.h"
+#include "bladerunner/script/aiscript_officer_leroy.h"
namespace BladeRunner {
@@ -47,8 +53,6 @@ bool Script::open(const Common::String &name) {
if (name == "RC01") { _currentScript = new ScriptRC01(_vm); return true; }
- _currentScript = new ScriptRC01(_vm); return true;
-
return false;
}
@@ -68,6 +72,26 @@ void Script::SceneLoaded() {
_inScriptCounter--;
}
+bool Script::ClickedOn3DObject(const char *objectName) {
+ if (_inScriptCounter > 0)
+ return true;
+
+ _inScriptCounter++;
+ bool result = _currentScript->ClickedOn3DObject(objectName);
+ _inScriptCounter--;
+ return result;
+}
+
+bool Script::ClickedOn2DRegion(int region) {
+ if (_inScriptCounter > 0)
+ return true;
+
+ _inScriptCounter++;
+ bool result = _currentScript->ClickedOn2DRegion(region);
+ _inScriptCounter--;
+ return result;
+}
+
void Script::SceneFrameAdvanced(int frame) {
_inScriptCounter++;
_currentScript->SceneFrameAdvanced(frame);
@@ -80,6 +104,12 @@ void Script::SceneActorChangedGoal(int actorId, int newGoal, int oldGoal, bool c
_inScriptCounter--;
}
+void Script::PlayerWalkedIn() {
+ _inScriptCounter++;
+ _currentScript->PlayerWalkedIn();
+ _inScriptCounter--;
+}
+
void ScriptBase::Preload(int animationId) {
_vm->_sliceRenderer->preload(animationId);
}
@@ -88,12 +118,12 @@ void ScriptBase::Actor_Put_In_Set(int actorId, int setId) {
_vm->_actors[actorId]->setSetId(setId);
}
-void ScriptBase::Actor_Set_At_XYZ(int actorId, float x, float y, float z, int angle) {
- _vm->_actors[actorId]->set_at_xyz(Vector3(x, y, z), angle, true, 0, 0);
+void ScriptBase::Actor_Set_At_XYZ(int actorId, float x, float y, float z, int direction) {
+ _vm->_actors[actorId]->setAtXYZ(Vector3(x, y, z), direction);
}
void ScriptBase::Actor_Set_At_Waypoint(int actorId, int waypointId, int angle) {
- _vm->_actors[actorId]->set_at_waypoint(waypointId, angle, 0, 0);
+ _vm->_actors[actorId]->setAtWaypoint(waypointId, angle, 0, 0);
}
bool ScriptBase::Region_Check(int left, int top, int right, int down) {
@@ -101,10 +131,16 @@ bool ScriptBase::Region_Check(int left, int top, int right, int down) {
return false;
}
-// ScriptBase::Object_Query_Click
-// ScriptBase::Object_Do_Ground_Click
+bool ScriptBase::Object_Query_Click(const char *objectName1, const char *objectName2) {
+ return strcmp(objectName1, objectName2) == 0;
+}
+
+void ScriptBase::Object_Do_Ground_Click() {
+ //This is not implemented in game
+ return;
+}
-bool ScriptBase::Object_Mark_For_Hot_Mouse(char *objectName) {
+bool ScriptBase::Object_Mark_For_Hot_Mouse(const char *objectName) {
int objectId = _vm->_scene->findObject(objectName);
if (objectId == -1)
return false;
@@ -115,7 +151,7 @@ void ScriptBase::Actor_Face_Actor(int actorId, int otherActorId, bool animate) {
_vm->_actors[actorId]->faceActor(otherActorId, animate);
}
-void ScriptBase::Actor_Face_Object(int actorId, char *objectName, bool animate) {
+void ScriptBase::Actor_Face_Object(int actorId, const char *objectName, bool animate) {
_vm->_actors[actorId]->faceObject(objectName, animate);
}
@@ -242,7 +278,7 @@ void ScriptBase::Actor_Set_Health(int actorId, int hp, int maxHp) {
void ScriptBase::Actor_Set_Targetable(int actorId, bool targetable) {
_vm->_actors[actorId]->setTargetable(targetable);
-
+
}
void ScriptBase::Actor_Says(int actorId, int sentenceId, int animationMode){
@@ -302,6 +338,29 @@ void ScriptBase::Actor_Says_With_Pause(int actorId, int sentenceId, float pause,
Player_Gains_Control();
}
+#if 0
+void ScriptBase::Actor_Voice_Over(int sentenceId, int actorId) {
+ // Wait for any existing speech to end
+ _vm->loopActorSpeaking();
+
+ // TODO: Hack - This needs to go through the actor class
+ char name[13];
+ sprintf(name, "%02d-%04d.AUD", actorId, sentenceId);
+ _vm->_audioSpeech->playSpeech(name);
+
+ // warning("start voice over loop");
+ while (true)
+ {
+ _vm->gameTick();
+ if (_vm->shouldQuit())
+ break;
+ if (!_vm->_audioSpeech->isPlaying())
+ break;
+ }
+ // warning("end voice over loop");
+}
+#endif
+
void ScriptBase::Actor_Voice_Over(int sentenceId, int actorId) {
_vm->gameWaitForActive();
_vm->loopActorSpeaking();
@@ -328,7 +387,7 @@ void ScriptBase::Actor_Start_Speech_Sample(int actorId, int sentenceId) {
}
void ScriptBase::Actor_Start_Voice_Over_Sample(int sentenceId) {
- _vm->loopActorSpeaking();
+ _vm->loopActorSpeaking();
_vm->_voiceoverActor->speechPlay(sentenceId, true);
}
@@ -397,11 +456,11 @@ int ScriptBase::Actor_Query_Facing_1024(int actorId) {
}
void ScriptBase::Actor_Set_Frame_Rate_FPS(int actorId, int fps) {
- _vm->_actors[actorId]->setFps(fps);
+ _vm->_actors[actorId]->setFPS(fps);
}
-int ScriptBase::Slice_Animation_Query_Number_Of_Frames(int animationId) {
- return _vm->_sliceAnimations->getNumberOfFrames(animationId);
+int ScriptBase::Slice_Animation_Query_Number_Of_Frames(int animation) {
+ return _vm->_sliceAnimations->getFrameCount(animation);
}
void ScriptBase::Actor_Change_Animation_Mode(int actorId, int animationMode) {
@@ -414,9 +473,21 @@ int ScriptBase::Actor_Query_Animation_Mode(int actorId) {
// ScriptBase::Loop_Actor_Walk_To_Actor
// ScriptBase::Loop_Actor_Walk_To_Item
-// ScriptBase::Loop_Actor_Walk_To_Scene_Object
+
+bool ScriptBase::Loop_Actor_Walk_To_Scene_Object(int actorId, const char *objectName, int distance, int a4, int a5) {
+ _vm->gameWaitForActive();
+
+ _vm->_actors[actorId]->loopWalkToSceneObject(objectName);
+
+ return false;
+}
+
// ScriptBase::Loop_Actor_Walk_To_Waypoint
-// ScriptBase::Loop_Actor_Walk_To_XYZ
+
+void ScriptBase::Loop_Actor_Walk_To_XYZ(int actorId, float x, float y, float z, int a4, int a5, int a6, int a7) {
+ _vm->loopActorWalkToXYZ(actorId, x, y, z, a4, a5, a6, a7);
+}
+
// ScriptBase::Async_Actor_Walk_To_Waypoint
// ScriptBase::Async_Actor_Walk_To_XYZ
// ScriptBase::Actor_Force_Stop_Walking
@@ -487,30 +558,28 @@ int ScriptBase::Animation_Skip_To_Frame() {
return 0;
}
-
void ScriptBase::Delay(int miliseconds) {
Player_Loses_Control();
int endTime = _vm->getTotalPlayTime() + miliseconds;
while ((int)_vm->getTotalPlayTime() < endTime)
_vm->gameTick();
Player_Gains_Control();
-
}
void ScriptBase::Player_Loses_Control() {
- _vm->playerLosesControl();
+ _vm->playerLosesControl();
}
void ScriptBase::Player_Gains_Control() {
- _vm->playerGainsControl();
+ _vm->playerGainsControl();
}
void ScriptBase::Player_Set_Combat_Mode(bool activate) {
- if(!_vm->_combat->isActive() || activate) {
- if(_vm->_combat->isActive() && activate) {
+ if (!_vm->_combat->isActive() || activate) {
+ if (_vm->_combat->isActive() && activate) {
_vm->_combat->activate();
}
- }else {
+ } else {
_vm->_combat->deactivate();
}
}
@@ -520,9 +589,9 @@ bool ScriptBase::Player_Query_Combat_Mode() {
}
void ScriptBase::Player_Set_Combat_Mode_Access(bool enable) {
- if(enable) {
+ if (enable) {
_vm->_combat->enable();
- }else {
+ } else {
_vm->_combat->disable();
}
}
@@ -547,6 +616,7 @@ int ScriptBase::Query_Difficulty_Level() {
return _vm->_settings->getDifficulty();
}
+
void ScriptBase::Game_Flag_Set(int flag) {
_vm->_gameFlags->set(flag);
}
@@ -614,11 +684,17 @@ void ScriptBase::Sound_Play(int id, int volume, int panFrom, int panTo, int prio
// ScriptBase::Overlay_Remove
void ScriptBase::Scene_Loop_Set_Default(int a) {
- debug("Scene_Loop_Set_Default(%d)", a);
+ // debug("Scene_Loop_Set_Default(%d)", a);
+
+ _vm->_scene->loopSetDefault(a);
+ // _vm->_scene->_defaultLoop = a;
}
void ScriptBase::Scene_Loop_Start_Special(int a, int b, int c) {
- debug("Scene_Loop_Start_Special(%d, %d, %d)", a, b, c);
+ // debug("Scene_Loop_Start_Special(%d, %d, %d)", a, b, c);
+
+ _vm->_scene->loopStartSpecial(a, b, c);
+ // _vm->_scene->_field_24_loop_start_special_param_1 = a;
}
void ScriptBase::Outtake_Play(int id, int noLocalization, int container) {
@@ -725,7 +801,7 @@ void ScriptBase::Scene_2D_Region_Remove(int index) {
// ScriptBase::Query_Score
void ScriptBase::Set_Score(int a0, int a1) {
- debug("STUB: Set_Score(%d, %d)", a0, a1);
+ // debug("STUB: Set_Score(%d, %d)", a0, a1);
}
void ScriptBase::Give_McCoy_Ammo(int ammoType, int ammo) {
@@ -757,32 +833,32 @@ void ScriptBase::Actor_Retired_Here(int actorId, int width, int height, int reti
Vector3 actorPosition;
actor->getXYZ(&actorPosition.x, &actorPosition.y, &actorPosition.z);
actor->retire(retired, width, height, retiredByActorId);
- actor->set_at_xyz(actorPosition, actor->getFacing(), true, 0, true);
+ actor->setAtXYZ(actorPosition, actor->getFacing(), true, 0, true);
_vm->_sceneObjects->setRetired(actorId, true);
}
-void ScriptBase::Clickable_Object(char *objectName) {
+void ScriptBase::Clickable_Object(const char *objectName) {
int objectId = _vm->_scene->findObject(objectName);
if (objectId == -1)
return;
_vm->_scene->objectSetIsClickable(objectId, true, !_vm->_sceneIsLoading);
}
-void ScriptBase::Unclickable_Object(char *objectName) {
+void ScriptBase::Unclickable_Object(const char *objectName) {
int objectId = _vm->_scene->findObject(objectName);
if (objectId == -1)
return;
_vm->_scene->objectSetIsClickable(objectId, false, !_vm->_sceneIsLoading);
}
-void ScriptBase::Obstacle_Object(char *objectName, bool updateWalkpath) {
+void ScriptBase::Obstacle_Object(const char *objectName, bool updateWalkpath) {
int objectId = _vm->_scene->findObject(objectName);
if (objectId == -1)
return;
_vm->_scene->objectSetIsObstacle(objectId, true, !_vm->_sceneIsLoading, !_vm->_sceneIsLoading && updateWalkpath);
}
-void ScriptBase::Unobstacle_Object(char *objectName, bool updateWalkpath) {
+void ScriptBase::Unobstacle_Object(const char *objectName, bool updateWalkpath) {
int objectId = _vm->_scene->findObject(objectName);
if (objectId == -1)
return;
@@ -793,18 +869,18 @@ void ScriptBase::Obstacle_Flag_All_Objects(bool isObstacle) {
_vm->_scene->objectSetIsObstacleAll(isObstacle, !_vm->_sceneIsLoading);
}
-void ScriptBase::Combat_Target_Object(char *objectName) {
+void ScriptBase::Combat_Target_Object(const char *objectName) {
int objectId = _vm->_scene->findObject(objectName);
if (objectId == -1)
return;
- _vm->_scene->objectSetIsCombatTarget(objectId, true, !_vm->_sceneIsLoading);
+ _vm->_scene->objectSetIsTarget(objectId, true, !_vm->_sceneIsLoading);
}
-void ScriptBase::Un_Combat_Target_Object(char *objectName) {
+void ScriptBase::Un_Combat_Target_Object(const char *objectName) {
int objectId = _vm->_scene->findObject(objectName);
if (objectId == -1)
return;
- _vm->_scene->objectSetIsCombatTarget(objectId, true, !_vm->_sceneIsLoading);
+ _vm->_scene->objectSetIsTarget(objectId, true, !_vm->_sceneIsLoading);
}
void ScriptBase::Set_Fade_Color(float r, float g, float b) {
@@ -841,5 +917,37 @@ void ScriptBase::I_Sez(const char *str) {
_vm->ISez(str);
}
+AIScripts::AIScripts(BladeRunnerEngine *vm)
+ : _vm(vm),
+ _inScriptCounter(0)
+{
+ for (int i = 0; i != 100; ++i)
+ _AIScripts[i] = 0;
+
+ _AIScripts[0] = new AIScript_McCoy(_vm);
+ _AIScripts[23] = new AIScript_Officer_Leroy(_vm);
+}
+
+void AIScripts::Initialize(int actor)
+{
+ if (_AIScripts[actor])
+ _AIScripts[actor]->Initialize();
+}
+
+void AIScripts::UpdateAnimation(int actor, int *animation, int *frame)
+{
+ _inScriptCounter++;
+ if (_AIScripts[actor])
+ _AIScripts[actor]->UpdateAnimation(animation, frame);
+ _inScriptCounter--;
+}
+
+void AIScripts::ChangeAnimationMode(int actor, int mode)
+{
+ _inScriptCounter++;
+ if (_AIScripts[actor])
+ _AIScripts[actor]->ChangeAnimationMode(mode);
+ _inScriptCounter--;
+}
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/script/script.h b/engines/bladerunner/script/script.h
index 97db6eb425..8f38657ae0 100644
--- a/engines/bladerunner/script/script.h
+++ b/engines/bladerunner/script/script.h
@@ -42,15 +42,15 @@ public:
protected:
void Preload(int animationId);
- void Actor_Put_In_Set(int actorId, int setId);
- void Actor_Set_At_XYZ(int actorId, float x, float y, float z, int angle);
+ void Actor_Put_In_Set(int id, int set);
+ void Actor_Set_At_XYZ(int actorId, float x, float y, float z, int direction);
void Actor_Set_At_Waypoint(int actorId, int waypointId, int angle);
bool Region_Check(int left, int top, int right, int down);
- // Object_Query_Click
- // Object_Do_Ground_Click
- bool Object_Mark_For_Hot_Mouse(char *objectName);
+ bool Object_Query_Click(const char *objectName1, const char *objectName2);
+ void Object_Do_Ground_Click();
+ bool Object_Mark_For_Hot_Mouse(const char *objectName);
void Actor_Face_Actor(int actorId, int otherActorId, bool animate);
- void Actor_Face_Object(int actorId, char *objectName, bool animate);
+ void Actor_Face_Object(int actorId, const char *objectName, bool animate);
void Actor_Face_Item(int actorId, int itemId, bool animate);
void Actor_Face_Waypoint(int actorId, int waypointId, bool animate);
void Actor_Face_XYZ(int actorId, float x, float y, float z, bool animate);
@@ -103,9 +103,9 @@ protected:
int Actor_Query_Animation_Mode(int actorId);
// Loop_Actor_Walk_To_Actor
// Loop_Actor_Walk_To_Item
- // Loop_Actor_Walk_To_Scene_Object
+ bool Loop_Actor_Walk_To_Scene_Object(int actorId, const char *objectName, int distance, int a4, int a5);
// Loop_Actor_Walk_To_Waypoint
- // Loop_Actor_Walk_To_XYZ
+ void Loop_Actor_Walk_To_XYZ(int actorId, float x, float y, float z, int a4, int a5, int a6, int a7);
// Async_Actor_Walk_To_Waypoint
// Async_Actor_Walk_To_XYZ
// Actor_Force_Stop_Walking
@@ -241,13 +241,13 @@ protected:
void Disable_Shadows(int *animationsIdsList, int listSize);
bool Query_System_Currently_Loading_Game();
void Actor_Retired_Here(int actorId, int width, int height, int retired, int retiredByActorId);
- void Clickable_Object(char *objectName);
- void Unclickable_Object(char *objectName);
- void Obstacle_Object(char *objectName, bool updateWalkpath);
- void Unobstacle_Object(char *objectName, bool updateWalkpath);
+ void Clickable_Object(const char *objectName);
+ void Unclickable_Object(const char *objectName);
+ void Obstacle_Object(const char *objectName, bool updateWalkpath);
+ void Unobstacle_Object(const char *objectName, bool updateWalkpath);
void Obstacle_Flag_All_Objects(bool isObstacle);
- void Combat_Target_Object(char *objectName);
- void Un_Combat_Target_Object(char *objectName);
+ void Combat_Target_Object(const char *objectName);
+ void Un_Combat_Target_Object(const char *objectName);
void Set_Fade_Color(float r, float g, float b);
void Set_Fade_Density(float density);
void Set_Fog_Color(char* fogName, float r, float g, float b);
@@ -268,10 +268,17 @@ public:
virtual void InitializeScene() = 0;
virtual void SceneLoaded() = 0;
+ virtual bool ClickedOn3DObject(const char *objectName) = 0;
+ virtual bool ClickedOn2DRegion(int region) = 0;
virtual void SceneFrameAdvanced(int frame) = 0;
virtual void SceneActorChangedGoal(int actorId, int newGoal, int oldGoal, bool currentSet) = 0;
+ virtual void PlayerWalkedIn() = 0;
};
+/*
+ * Scene Scripts
+ */
+
class Script {
public:
BladeRunnerEngine *_vm;
@@ -289,8 +296,11 @@ public:
void InitializeScene();
void SceneLoaded();
+ bool ClickedOn3DObject(const char *objectName);
+ bool ClickedOn2DRegion(int region);
void SceneFrameAdvanced(int frame);
void SceneActorChangedGoal(int actorId, int newGoal, int oldGoal, bool currentSet);
+ void PlayerWalkedIn();
};
#define DECLARE_SCRIPT(name) \
@@ -301,14 +311,49 @@ public: \
{} \
void InitializeScene(); \
void SceneLoaded(); \
+ bool ClickedOn3DObject(const char *objectName); \
+ bool ClickedOn2DRegion(int region); \
void SceneFrameAdvanced(int frame); \
void SceneActorChangedGoal(int actorId, int newGoal, int oldGoal, bool currentSet); \
-};
+ void PlayerWalkedIn(); \
+private:
+#define END_SCRIPT };
DECLARE_SCRIPT(RC01)
+ void sub_403850();
+END_SCRIPT
#undef DECLARE_SCRIPT
+/*
+ * Actor Scripts
+ */
+
+class AIScriptBase : public ScriptBase {
+public:
+ AIScriptBase(BladeRunnerEngine *vm)
+ : ScriptBase(vm)
+ {}
+
+ virtual void Initialize() = 0;
+ virtual void UpdateAnimation(int *animation, int *frame) = 0;
+ virtual void ChangeAnimationMode(int mode) = 0;
+};
+
+class AIScripts {
+public:
+ BladeRunnerEngine *_vm;
+ int _inScriptCounter;
+ AIScriptBase *_AIScripts[100];
+
+ AIScripts(BladeRunnerEngine *vm);
+ ~AIScripts();
+
+ void Initialize(int actor);
+ void UpdateAnimation(int actor, int *animation, int *frame);
+ void ChangeAnimationMode(int actor, int mode);
+};
+
} // End of namespace BladeRunner
#endif
diff --git a/engines/bladerunner/set.cpp b/engines/bladerunner/set.cpp
index 070fd64498..e07a37a99c 100644
--- a/engines/bladerunner/set.cpp
+++ b/engines/bladerunner/set.cpp
@@ -23,14 +23,13 @@
#include "bladerunner/set.h"
#include "bladerunner/bladerunner.h"
-#include "bladerunner/slice_renderer.h"
+#include "bladerunner/scene_objects.h"
#include "common/debug.h"
#include "common/ptr.h"
#include "common/str.h"
#include "common/stream.h"
-
namespace BladeRunner {
#define kSet0 0x53657430
@@ -40,12 +39,9 @@ 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;
}
@@ -57,7 +53,7 @@ bool Set::open(const Common::String &name) {
if (sig != kSet0)
return false;
- int framesCount = s->readUint32LE();
+ s->skip(4); // TODO: LITE length
_objectCount = s->readUint32LE();
assert(_objectCount <= 85);
@@ -78,10 +74,10 @@ bool Set::open(const Common::String &name) {
_objects[i]._isObstacle = s->readByte();
_objects[i]._isClickable = s->readByte();
_objects[i]._isHotMouse = 0;
- _objects[i]._isCombatTarget = 0;
+ _objects[i]._isTarget = 0;
s->skip(4);
- // debug("OBJECT: %s", _objects[i]._name);
+ // debug("OBJECT: %s [%d%d%d%d]", _objects[i]._name, _objects[i]._isObstacle, _objects[i]._isClickable, _objects[i]._isHotMouse, _objects[i]._isTarget);
}
_walkboxCount = s->readUint32LE();
@@ -106,51 +102,49 @@ bool Set::open(const Common::String &name) {
// debug("WALKBOX: %s", _walkboxes[i]._name);
}
- _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);
+ // TODO: Read LITE
return true;
}
-
void Set::addObjectsToScene(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);
+ sceneObjects->addObject(i + SCENE_OBJECTS_OBJECTS_OFFSET, &_objects[i]._bbox, _objects[i]._isClickable, _objects[i]._isObstacle, _objects[i]._unknown1, _objects[i]._isTarget);
}
}
-
-int Set::findWalkbox(float x, float z) {
- int i;
- float altitude = 0.0f;
- int foundWalkboxId = -1;
- for (i = 0; i < (int)_walkboxCount; i++) {
- if (isXzInWalkbox(x, z, &_walkboxes[i])) {
- if (foundWalkboxId == -1 || altitude < _walkboxes[i]._altitude) {
- altitude = _walkboxes[i]._altitude;
- foundWalkboxId = i;
- }
+// Source: http://www.faqs.org/faqs/graphics/algorithms-faq/ section 2.03
+/*
+static
+bool pointInWalkbox(float x, float z, const Walkbox &w)
+{
+ uint32 i, j;
+ bool c = false;
+
+ for (i = 0, j = w._vertexCount - 1; i < w._vertexCount; j = i++) {
+ if ((((w._vertices[i].z <= z) && (z < w._vertices[j].z)) ||
+ ((w._vertices[j].z <= z) && (z < w._vertices[i].z))) &&
+ (x < (w._vertices[j].x - w._vertices[i].x) * (z - w._vertices[i].z) / (w._vertices[j].z - w._vertices[i].z) + w._vertices[i].x))
+ {
+ c = !c;
}
}
- return foundWalkboxId;
+ return c;
}
+*/
-bool Set::isXzInWalkbox(float x, float z, Walkbox* walkbox) {
+static
+bool isXZInWalkbox(float x, float z, const Walkbox &walkbox) {
int found = 0;
int i;
- float lastX = walkbox->_vertices[walkbox->_vertexCount - 1].x;
- float lastZ = walkbox->_vertices[walkbox->_vertexCount - 1].z;
- for (i = 0; i < (int)walkbox->_vertexCount; i++) {
-
- float currentX = walkbox->_vertices[i].x;
- float currentZ = walkbox->_vertices[i].z;
+ float lastX = walkbox._vertices[walkbox._vertexCount - 1].x;
+ float lastZ = walkbox._vertices[walkbox._vertexCount - 1].z;
+ for (i = 0; i < (int)walkbox._vertexCount; i++) {
+ float currentX = walkbox._vertices[i].x;
+ float currentZ = walkbox._vertices[i].z;
if ((currentZ > z && z >= lastZ) || (currentZ <= z && z < lastZ)) {
float lineX = (lastX - currentX) / (lastZ - currentZ) * (z - currentZ) + currentX;
@@ -162,14 +156,50 @@ bool Set::isXzInWalkbox(float x, float z, Walkbox* walkbox) {
return found & 1;
}
+float Set::getAltitudeAtXZ(float x, float z, bool *inWalkbox) {
+ float altitude = _walkboxes[0]._altitude;
+ *inWalkbox = false;
+
+ for (uint32 i = 0; i != _walkboxCount; ++i) {
+ const Walkbox &w = _walkboxes[i];
+
+ if (isXZInWalkbox(x, z, w)) {
+ *inWalkbox = true;
+ if (w._altitude > altitude) {
+ altitude = w._altitude;
+ }
+ }
+ }
+
+ return altitude;
+}
+
+int Set::findWalkbox(float x, float z) {
+ int result = -1;
+
+ for (uint32 i = 0; i != _walkboxCount; ++i) {
+ const Walkbox &w = _walkboxes[i];
+
+ if (isXZInWalkbox(x, z, w)) {
+ if (result == -1 || w._altitude > _walkboxes[result]._altitude) {
+ result = i;
+ }
+ }
+ }
+
+ return result;
+}
-int Set::findObject(char* objectName) {
- int i;
+int Set::findObject(const char *objectName) {
+ int i;
for (i = 0; i < (int)_objectCount; i++) {
if (scumm_stricmp(objectName, _objects[i]._name) == 0) {
return i;
}
}
+
+ debug("Set::findObject didn't find \"%s\"", objectName);
+
return -1;
}
@@ -177,22 +207,22 @@ bool Set::objectSetHotMouse(int objectId) {
if(!_objects || objectId < 0 || objectId >= (int)_objectCount) {
return false;
}
-
+
_objects[objectId]._isHotMouse = true;
return true;
}
-bool Set::objectGetBoundingBox(int objectId, BoundingBox* boundingBox) {
+bool Set::objectGetBoundingBox(int objectId, BoundingBox *boundingBox) {
assert(boundingBox);
if (!_objects || objectId < 0 || objectId >= (int)_objectCount) {
- boundingBox->setXyz(0, 0, 0, 0, 0, 0);
+ boundingBox->setXYZ(0, 0, 0, 0, 0, 0);
return false;
}
float x0, y0, z0, x1, y1, z1;
- _objects[objectId]._bbox.getXyz(&x0, &y0, &z0, &x1, &y1, &z1);
- boundingBox->setXyz(x0, y0, z0, x1, y1, z1);
+ _objects[objectId]._bbox.getXYZ(&x0, &y0, &z0, &x1, &y1, &z1);
+ boundingBox->setXYZ(x0, y0, z0, x1, y1, z1);
return true;
}
@@ -205,8 +235,12 @@ void Set::objectSetIsObstacle(int objectId, bool isObstacle) {
_objects[objectId]._isObstacle = isObstacle;
}
-void Set::objectSetIsCombatTarget(int objectId, bool isCombatTarget) {
- _objects[objectId]._isCombatTarget = isCombatTarget;
+void Set::objectSetIsTarget(int objectId, bool isTarget) {
+ _objects[objectId]._isTarget = isTarget;
+}
+
+const char *Set::objectGetName(int objectId) {
+ return _objects[objectId]._name;
}
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/set.h b/engines/bladerunner/set.h
index 2db9c826eb..18fde76ee3 100644
--- a/engines/bladerunner/set.h
+++ b/engines/bladerunner/set.h
@@ -24,10 +24,6 @@
#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"
@@ -35,8 +31,10 @@
namespace BladeRunner {
class BladeRunnerEngine;
+
class VQADecoder;
-class Scene;
+class SetEffects;
+class SceneObjects;
struct Object {
char _name[20];
@@ -44,7 +42,7 @@ struct Object {
uint8 _isObstacle;
uint8 _isClickable;
uint8 _isHotMouse;
- uint8 _isCombatTarget;
+ uint8 _isTarget;
uint8 _unknown1;
};
@@ -56,8 +54,6 @@ struct Walkbox {
};
class Set {
- friend class Scene;
-
BladeRunnerEngine *_vm;
uint32 _objectCount;
@@ -66,6 +62,7 @@ class Set {
Walkbox *_walkboxes;
int _walkboxStepSound[85];
int _footstepSoundOverride;
+ float _unknown[10];
public:
SetEffects *_effects;
@@ -74,20 +71,21 @@ public:
~Set();
bool open(const Common::String &name);
+
void addObjectsToScene(SceneObjects *sceneObjects);
+ uint32 getObjectCount() { return _objectCount; }
+
+ float getAltitudeAtXZ(float x, float z, bool *inWalkbox);
int findWalkbox(float x, float z);
- int findObject(char* objectName);
+ int findObject(const char *objectName);
bool objectSetHotMouse(int objectId);
bool objectGetBoundingBox(int objectId, BoundingBox *boundingBox);
void objectSetIsClickable(int objectId, bool isClickable);
void objectSetIsObstacle(int objectId, bool isObstacle);
- void objectSetIsCombatTarget(int objectId, bool isCombatTarget);
-
-private:
- bool isXzInWalkbox(float x, float z, Walkbox* walkbox);
-
+ void objectSetIsTarget(int objectId, bool isTarget);
+ const char *objectGetName(int objectId);
};
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/set_effects.cpp b/engines/bladerunner/set_effects.cpp
index 6db81ce631..bc10a0fc2c 100644
--- a/engines/bladerunner/set_effects.cpp
+++ b/engines/bladerunner/set_effects.cpp
@@ -1,7 +1,6 @@
#include "bladerunner/set_effects.h"
-namespace BladeRunner
-{
+namespace BladeRunner {
SetEffects::SetEffects(BladeRunnerEngine* vm) {
_vm = vm;
@@ -119,4 +118,4 @@ Fog* SetEffects::findFog(char* fogName) {
return fog;
}
-} \ No newline at end of file
+} // End of namespace BladeRunner
diff --git a/engines/bladerunner/set_effects.h b/engines/bladerunner/set_effects.h
index 8f628075fe..16317ed3e1 100644
--- a/engines/bladerunner/set_effects.h
+++ b/engines/bladerunner/set_effects.h
@@ -1,24 +1,24 @@
/* 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.
-*
-*/
+ *
+ * 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
@@ -63,5 +63,6 @@ private:
};
-}
+} // End of namespace BladeRunner
+
#endif
diff --git a/engines/bladerunner/settings.cpp b/engines/bladerunner/settings.cpp
index 100f492401..0c3a774a4f 100644
--- a/engines/bladerunner/settings.cpp
+++ b/engines/bladerunner/settings.cpp
@@ -95,7 +95,6 @@ bool Settings::openNewScene() {
return true;
}
-
int Settings::getAmmoType() {
return _ammoType;
}
@@ -122,6 +121,4 @@ void Settings::setPlayerAgenda(int agenda) {
_playerAgenda = agenda;
}
-
-
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/settings.h b/engines/bladerunner/settings.h
index e45eb32e88..de9846a854 100644
--- a/engines/bladerunner/settings.h
+++ b/engines/bladerunner/settings.h
@@ -46,7 +46,7 @@ class Settings {
int _difficulty;
int _playerAgenda;
-
+
int _ammoType;
int _ammoAmounts[3];
diff --git a/engines/bladerunner/slice_animations.cpp b/engines/bladerunner/slice_animations.cpp
index b813c13a3d..7061dd975a 100644
--- a/engines/bladerunner/slice_animations.cpp
+++ b/engines/bladerunner/slice_animations.cpp
@@ -63,14 +63,14 @@ bool SliceAnimations::open(const Common::String &name) {
_animations.resize(animationCount);
for (uint32 i = 0; i != animationCount; ++i) {
- _animations[i].frameCount = file.readUint32LE();
- _animations[i].frameSize = file.readUint32LE();
- _animations[i].fps = file.readFloatLE();
- _animations[i].positionChange.x = file.readFloatLE();
- _animations[i].positionChange.y = file.readFloatLE();
- _animations[i].positionChange.z = file.readFloatLE();
- _animations[i].facingChange = file.readFloatLE();
- _animations[i].offset = file.readUint32LE();
+ _animations[i].frameCount = file.readUint32LE();
+ _animations[i].frameSize = file.readUint32LE();
+ _animations[i].fps = file.readFloatLE();
+ _animations[i].unk0 = file.readFloatLE();
+ _animations[i].unk1 = file.readFloatLE();
+ _animations[i].unk2 = file.readFloatLE();
+ _animations[i].unk3 = file.readFloatLE();
+ _animations[i].offset = file.readUint32LE();
#if 0
debug("%4d %6d %6x %7.2g %7.2g %7.2g %7.2g %7.2g %8x",
@@ -128,7 +128,7 @@ bool SliceAnimations::PageFile::open(const Common::String &name) {
_pageOffsets[pageNumber] = dataOffset + i * _sliceAnimations->_pageSize;
}
- debug("PageFile::Open: page file \"%s\" opened with %d pages", name.c_str(), pageCount);
+ // debug("PageFile::Open: page file \"%s\" opened with %d pages", name.c_str(), pageCount);
return true;
}
@@ -170,18 +170,4 @@ void *SliceAnimations::getFramePtr(uint32 animation, uint32 frame) {
return (byte*)_pages[page]._data + pageOffset;
}
-
-int SliceAnimations::getNumberOfFrames(int animationId) {
- if (animationId > (int)_animations.size())
- return 0;
- return _animations[animationId].frameCount;
-}
-
-
-float SliceAnimations::getFps(int animationId) {
- if (animationId > (int)_animations.size())
- return 15.0f;
- return _animations[animationId].fps;
-}
-
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/slice_animations.h b/engines/bladerunner/slice_animations.h
index 9af12e41c2..ac254d429f 100644
--- a/engines/bladerunner/slice_animations.h
+++ b/engines/bladerunner/slice_animations.h
@@ -23,8 +23,6 @@
#ifndef BLADERUNNER_SLICE_ANIMATIONS_H
#define BLADERUNNER_SLICE_ANIMATIONS_H
-#include "bladerunner/vector.h"
-
#include "common/array.h"
#include "common/file.h"
#include "common/str.h"
@@ -48,8 +46,10 @@ class SliceAnimations {
uint32 frameCount;
uint32 frameSize;
float fps;
- Vector3 positionChange;
- float facingChange;
+ float unk0;
+ float unk1;
+ float unk2;
+ float unk3;
uint32 offset;
};
@@ -102,10 +102,11 @@ public:
bool openCoreAnim();
bool openHDFrames();
- SlicePalette &getPalette(int i) { return _palettes[i]; }
+ SlicePalette &getPalette(int i) { return _palettes[i]; };
void *getFramePtr(uint32 animation, uint32 frame);
- int getNumberOfFrames(int animationId);
- float getFps(int animationId);
+
+ float getFrameCount(int animation){ return _animations[animation].frameCount; }
+ float getFPS(int animation){ return _animations[animation].fps; }
};
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/slice_renderer.cpp b/engines/bladerunner/slice_renderer.cpp
index 389d818e6f..581bed2e22 100644
--- a/engines/bladerunner/slice_renderer.cpp
+++ b/engines/bladerunner/slice_renderer.cpp
@@ -23,10 +23,9 @@
#include "bladerunner/slice_renderer.h"
#include "bladerunner/bladerunner.h"
-#include "bladerunner/slice_animations.h"
#include "bladerunner/lights.h"
-#include "bladerunner/scene.h"
-#include "bladerunner/set.h"
+#include "bladerunner/set_effects.h"
+#include "bladerunner/slice_animations.h"
#include "common/debug.h"
#include "common/memstream.h"
@@ -54,10 +53,9 @@ void dump(const char *str, Matrix4x3 m) {
}
#endif
-
SliceRenderer::SliceRenderer(BladeRunnerEngine* vm) {
_vm = vm;
- int i;
+ int i;
for (i = 0; i < 942; i++) { // yes, its going just to 942 and not 997
_animationsShadowEnabled[i] = true;
@@ -67,10 +65,18 @@ SliceRenderer::SliceRenderer(BladeRunnerEngine* vm) {
SliceRenderer::~SliceRenderer() {
}
-void SliceRenderer::setView(View *view) {
+void SliceRenderer::setView(const View &view) {
_view = view;
}
+void SliceRenderer::setLights(Lights* lights){
+ _lights = lights;
+}
+
+void SliceRenderer::setSetEffects(SetEffects* setEffects){
+ _setEffects = setEffects;
+}
+
void SliceRenderer::setupFrame(int animation, int frame, Vector3 position, float facing, float scale) {
_animation = animation;
_frame = frame;
@@ -97,7 +103,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);
@@ -120,7 +126,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);
@@ -135,7 +141,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,
@@ -143,13 +149,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);
@@ -337,9 +343,6 @@ 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(
@@ -349,9 +352,6 @@ 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]);
@@ -426,17 +426,10 @@ void SliceRenderer::drawSlice(int slice, uint16 *frameLinePtr, uint16 *zbufLineP
}
}
-void SliceRenderer::setLights(Lights* lights){
- _lights = lights;
-}
-
-void SliceRenderer::setSetEffects(SetEffects* setEffects){
- _setEffects = setEffects;
-}
-
void SliceRenderer::preload(int animationId) {
int i;
- for (i = 0; i < _vm->_sliceAnimations->getNumberOfFrames(animationId); i++)
+ int frameCount = _vm->_sliceAnimations->getFrameCount(animationId);
+ for (i = 0; i < frameCount; i++)
_vm->_sliceAnimations->getFramePtr(animationId, i);
}
diff --git a/engines/bladerunner/slice_renderer.h b/engines/bladerunner/slice_renderer.h
index c702616bf7..3dcd92271e 100644
--- a/engines/bladerunner/slice_renderer.h
+++ b/engines/bladerunner/slice_renderer.h
@@ -26,8 +26,6 @@
#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"
@@ -36,9 +34,10 @@ namespace Common {
}
namespace BladeRunner {
- class SetEffects;
- class BladeRunnerEngine;
+class BladeRunnerEngine;
+class Lights;
+class SetEffects;
class SliceRenderer {
BladeRunnerEngine *_vm;
@@ -49,7 +48,7 @@ class SliceRenderer {
float _facing;
float _scale;
- View *_view;
+ View _view;
Lights *_lights;
SetEffects *_setEffects;
@@ -89,7 +88,7 @@ public:
SliceRenderer(BladeRunnerEngine *vm);
~SliceRenderer();
- void setView(View *view);
+ void setView(const View &view);
void setLights(Lights *lights);
void setSetEffects(SetEffects *setEffects);
diff --git a/engines/bladerunner/text_resource.cpp b/engines/bladerunner/text_resource.cpp
index 3c074ee3a0..801808d7d1 100644
--- a/engines/bladerunner/text_resource.cpp
+++ b/engines/bladerunner/text_resource.cpp
@@ -80,6 +80,13 @@ bool TextResource::open(const char *name) {
s->read(_strings, remain);
+#if 0
+ debug("\n%s\n----------------", resName);
+ for (uint32 i = 0; i != (uint32)_count; ++i) {
+ debug("%3d: %s", i, getText(i));
+ }
+#endif
+
return true;
}
@@ -90,7 +97,7 @@ const char *TextResource::getText(uint32 id) {
}
}
- return nullptr;
+ return "";
}
} // End of namespace BladeRunner
diff --git a/engines/bladerunner/view.cpp b/engines/bladerunner/view.cpp
index 029f829c0d..b3b6ad8ad2 100644
--- a/engines/bladerunner/view.cpp
+++ b/engines/bladerunner/view.cpp
@@ -27,11 +27,6 @@
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 3e3a0e86b1..511ea66d1b 100644
--- a/engines/bladerunner/view.h
+++ b/engines/bladerunner/view.h
@@ -23,8 +23,6 @@
#ifndef BLADERUNNER_VIEW_H
#define BLADERUNNER_VIEW_H
-#include "bladerunner/bladerunner.h"
-
#include "matrix.h"
namespace Common {
@@ -34,7 +32,6 @@ namespace Common {
namespace BladeRunner {
class View {
- BladeRunnerEngine *_vm;
public:
float _fovX;
Matrix4x3 _frameViewMatrix;
@@ -47,12 +44,8 @@ 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 63378dc5e9..06036e737c 100644
--- a/engines/bladerunner/vqa_decoder.cpp
+++ b/engines/bladerunner/vqa_decoder.cpp
@@ -30,7 +30,6 @@
#include "common/array.h"
#include "common/util.h"
-#include "common/memstream.h"
namespace BladeRunner {
@@ -181,14 +180,14 @@ bool VQADecoder::loadStream(Common::SeekableReadStream *s) {
_videoTrack = new VQAVideoTrack(this);
_audioTrack = new VQAAudioTrack(this);
- /*
+#if 0
for (int i = 0; i != _loopInfo.loopCount; ++i) {
debug("LOOP %2d: %4d %4d %s", i,
_loopInfo.loops[i].begin,
_loopInfo.loops[i].end,
_loopInfo.loops[i].name.c_str());
}
- */
+#endif
return true;
}
@@ -244,6 +243,16 @@ void VQADecoder::readNextPacket() {
} while (chd.id != kVQFR);
}
+void VQADecoder::readPacket(int frame) {
+ if (frame < 0 || frame >= numFrames()) {
+ error("frame %d out of bounds, frame count is %d", frame, numFrames());
+ }
+
+ uint32 frameOffset = 2 * (_frameInfo[frame] & 0x0FFFFFFF);
+ _s->seek(frameOffset);
+ readNextPacket();
+}
+
bool VQADecoder::readVQHD(Common::SeekableReadStream *s, uint32 size)
{
if (size != 42)
@@ -515,6 +524,18 @@ bool VQADecoder::readLNIN(Common::SeekableReadStream *s, uint32 size)
return true;
}
+bool VQADecoder::getLoopBeginAndEndFrame(int loop, int *begin, int *end) {
+ assert(begin && end);
+
+ if (loop < 0 || loop >= _loopInfo.loopCount)
+ return false;
+
+ *begin = _loopInfo.loops[loop].begin;
+ *end = _loopInfo.loops[loop].end;
+
+ return true;
+}
+
bool VQADecoder::readCLIP(Common::SeekableReadStream *s, uint32 size) {
s->skip(roundup(size));
return true;
@@ -525,12 +546,7 @@ bool VQADecoder::readMFCI(Common::SeekableReadStream *s, uint32 size) {
return true;
}
-void VQADecoder::decodeView(View* view)
-{
- _videoTrack->decodeView(view);
-}
-
- VQADecoder::VQAVideoTrack::VQAVideoTrack(VQADecoder *vqaDecoder) {
+VQADecoder::VQAVideoTrack::VQAVideoTrack(VQADecoder *vqaDecoder) {
VQADecoder::Header *header = &vqaDecoder->_header;
_surface = nullptr;
@@ -566,8 +582,6 @@ void VQADecoder::decodeView(View* view)
_surface = new Graphics::Surface();
_surface->create(_width, _height, createRGB555());
-
- _viewData = new uint8[56];
}
VQADecoder::VQAVideoTrack::~VQAVideoTrack() {
@@ -575,12 +589,11 @@ VQADecoder::VQAVideoTrack::~VQAVideoTrack() {
delete[] _cbfz;
delete[] _zbufChunk;
delete[] _vpointer;
- delete[] _viewData;
if (_surface)
_surface->free();
delete _surface;
- delete _zbuffer;
+ delete[] _zbuffer;
}
uint16 VQADecoder::VQAVideoTrack::getWidth() const {
@@ -752,29 +765,18 @@ const uint16 *VQADecoder::VQAVideoTrack::decodeZBuffer()
return _zbuffer;
}
-
-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)
+bool VQADecoder::VQAVideoTrack::readVIEW(Common::SeekableReadStream *s, uint32 size)
{
if (size != 56)
return false;
- s->read(_viewData, 56);
+ _view.read(s);
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 c57372081d..fecc14db9b 100644
--- a/engines/bladerunner/vqa_decoder.h
+++ b/engines/bladerunner/vqa_decoder.h
@@ -48,12 +48,13 @@ public:
bool loadStream(Common::SeekableReadStream *s);
void readNextPacket();
+ void readPacket(int frame);
const Graphics::Surface *decodeVideoFrame();
const uint16 *decodeZBuffer();
Audio::SeekableAudioStream *decodeAudioFrame();
- void decodeView(View *view);
- //const View &getView() { return _videoTrack->getView(); }
+
+ const View &getView() { return _videoTrack->getView(); }
uint16 numFrames() const { return _header.numFrames; }
uint8 frameRate() const { return _header.frameRate; }
@@ -64,6 +65,8 @@ public:
bool hasAudio() const { return _header.channels != 0; }
uint16 frequency() const { return _header.freq; }
+ bool getLoopBeginAndEndFrame(int loop, int *begin, int *end);
+
protected:
private:
@@ -163,7 +166,7 @@ private:
int getFrameCount() const;
const Graphics::Surface *decodeVideoFrame();
const uint16 *decodeZBuffer();
- void decodeView(View *view);
+ const View &getView() { return _view; }
bool readVQFR(Common::SeekableReadStream *s, uint32 size);
bool readVPTR(Common::SeekableReadStream *s, uint32 size);
@@ -207,7 +210,7 @@ private:
int _curFrame;
- uint8 *_viewData;
+ View _view;
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 0a04d1b786..d7b53ff94c 100644
--- a/engines/bladerunner/vqa_player.cpp
+++ b/engines/bladerunner/vqa_player.cpp
@@ -60,17 +60,17 @@ int VQAPlayer::update() {
if (_curFrame == -1) {
_curFrame = 0;
if (_curFrame >= 0) {
- _decoder.readNextPacket();
+ _decoder.readPacket(_curFrame);
if (_hasAudio)
queueAudioFrame(_decoder.decodeAudioFrame());
_surface = _decoder.decodeVideoFrame();
_zBuffer = _decoder.decodeZBuffer();
- _decoder.decodeView(_view);
+ _view = _decoder.getView();
}
_decodedFrame = calcNextFrame(_curFrame);
if (_decodedFrame >= 0) {
- _decoder.readNextPacket();
+ _decoder.readPacket(_decodedFrame);
if (_hasAudio)
queueAudioFrame(_decoder.decodeAudioFrame());
}
@@ -89,12 +89,12 @@ int VQAPlayer::update() {
if (_curFrame >= 0) {
_surface = _decoder.decodeVideoFrame();
_zBuffer = _decoder.decodeZBuffer();
- _decoder.decodeView(_view);
+ _view = _decoder.getView();
}
_decodedFrame = calcNextFrame(_curFrame);
if (_decodedFrame >= 0) {
- _decoder.readNextPacket();
+ _decoder.readPacket(_decodedFrame);
if (_hasAudio)
queueAudioFrame(_decoder.decodeAudioFrame());
}
@@ -115,21 +115,46 @@ const uint16 *VQAPlayer::getZBuffer() const {
return _zBuffer;
}
-void VQAPlayer::setLoopSpecial(int loop, bool wait) {
- _loopSpecial = loop;
- if (!wait)
- _curLoop = -1;
+bool VQAPlayer::setLoop(int loop) {
+ int begin, end;
+ if (!_decoder.getLoopBeginAndEndFrame(loop, &begin, &end)) {
+ return false;
+ }
+
+ _curLoop = loop;
+ _loopBegin = begin;
+ _loopEnd = end;
+
+ // warning("\t\t\tActive Loop: %d - %d\n", begin, end);
+
+ return true;
}
-void VQAPlayer::setLoopDefault(int loop) {
- _loopDefault = loop;
+int VQAPlayer::getLoopBeginFrame(int loop) {
+ int begin, end;
+ if (!_decoder.getLoopBeginAndEndFrame(loop, &begin, &end)) {
+ return -1;
+ }
+ return begin;
+}
+
+int VQAPlayer::getLoopEndFrame(int loop) {
+ int begin, end;
+ if (!_decoder.getLoopBeginAndEndFrame(loop, &begin, &end)) {
+ return -1;
+ }
+ return end;
}
int VQAPlayer::calcNextFrame(int frame) const {
if (frame < 0)
return -3;
- frame += 1;
+ if (_curLoop != -1 && frame >= _loopEnd) {
+ frame = _loopBegin;
+ } else {
+ frame++;
+ }
if (frame == _decoder.numFrames())
frame = -3;
diff --git a/engines/bladerunner/vqa_player.h b/engines/bladerunner/vqa_player.h
index 98f1fcf51b..cc29832ee2 100644
--- a/engines/bladerunner/vqa_player.h
+++ b/engines/bladerunner/vqa_player.h
@@ -42,13 +42,13 @@ class VQAPlayer {
const uint16 *_zBuffer;
Audio::QueuingAudioStream *_audioStream;
- View *_view;
-
int _curFrame;
int _decodedFrame;
int _curLoop;
- int _loopSpecial;
- int _loopDefault;
+ int _loopBegin;
+ int _loopEnd;
+
+ View _view;
uint32 _nextFrameTime;
bool _hasAudio;
@@ -57,7 +57,7 @@ class VQAPlayer {
public:
- VQAPlayer(BladeRunnerEngine *vm, View *view)
+ VQAPlayer(BladeRunnerEngine *vm)
: _vm(vm),
_s(nullptr),
_surface(nullptr),
@@ -65,12 +65,11 @@ public:
_curFrame(-1),
_decodedFrame(-1),
_curLoop(-1),
- _loopSpecial(-1),
- _loopDefault(-1),
+ _loopBegin(-1),
+ _loopEnd(-1),
_nextFrameTime(0),
_hasAudio(false),
- _audioStarted(false),
- _view(view)
+ _audioStarted(false)
{}
~VQAPlayer() {
@@ -83,9 +82,14 @@ public:
int update();
const Graphics::Surface *getSurface() const;
const uint16 *getZBuffer() const;
+ const View &getView() const { return _view; }
+
+ bool setLoop(int loop);
+ // void setLoopSpecial(int loop, bool wait);
+ // void setLoopDefault(int loop);
- void setLoopSpecial(int loop, bool wait);
- void setLoopDefault(int loop);
+ int getLoopBeginFrame(int loop);
+ int getLoopEndFrame(int loop);
private:
int calcNextFrame(int frame) const;
diff --git a/engines/bladerunner/waypoints.cpp b/engines/bladerunner/waypoints.cpp
index 60d3422520..3229aafd86 100644
--- a/engines/bladerunner/waypoints.cpp
+++ b/engines/bladerunner/waypoints.cpp
@@ -9,7 +9,7 @@ Waypoints::Waypoints(BladeRunnerEngine* vm, int count) {
Waypoints::~Waypoints() {
}
-void Waypoints::getXyz(int waypointId, float *x, float *y, float *z) {
+void Waypoints::getXYZ(int waypointId, float *x, float *y, float *z) {
*x = 0;
*y = 0;
*z = 0;
@@ -64,4 +64,4 @@ float Waypoints::getZ(int waypointId) {
return _waypoints[waypointId]._position.z;
}
-} \ No newline at end of file
+} // End of namespace BladeRunner
diff --git a/engines/bladerunner/waypoints.h b/engines/bladerunner/waypoints.h
index 5ee4696220..6f58b63e41 100644
--- a/engines/bladerunner/waypoints.h
+++ b/engines/bladerunner/waypoints.h
@@ -28,33 +28,35 @@
#include "common/array.h"
-
namespace BladeRunner {
- struct Waypoint {
- int _setId;
- Vector3 _position;
- bool _present;
- };
-
- class Waypoints {
- BladeRunnerEngine *_vm;
- private:
- int _count;
- Waypoint *_waypoints;
- public:
- Waypoints(BladeRunnerEngine *vm, int count);
- ~Waypoints();
-
- void getXyz(int waypointId, float *x, float *y, float *z);
- float getX(int waypointId);
- float getY(int waypointId);
- float getZ(int waypointId);
- int getSetId(int waypointId);
-
- bool set(int waypointId, int setId, Vector3 position);
- bool reset(int waypointId);
- };
-}
+struct Waypoint {
+ int _setId;
+ Vector3 _position;
+ bool _present;
+};
+
+class Waypoints {
+ BladeRunnerEngine *_vm;
+
+private:
+ int _count;
+ Waypoint *_waypoints;
+
+public:
+ Waypoints(BladeRunnerEngine *vm, int count);
+ ~Waypoints();
+
+ void getXYZ(int waypointId, float *x, float *y, float *z);
+ float getX(int waypointId);
+ float getY(int waypointId);
+ float getZ(int waypointId);
+ int getSetId(int waypointId);
+
+ bool set(int waypointId, int setId, Vector3 position);
+ bool reset(int waypointId);
+};
+
+} // End of namespace BladeRunner
#endif