aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjohndoe1232014-03-18 16:00:51 +0100
committerEugene Sandulenko2018-07-20 06:43:33 +0000
commit3fc592df497b957b42aa4eec27f8f77f899e0700 (patch)
treeca9309350ab564c401d0fc03640075a770f78530
parentb3b0bd884dc0cec008cf050f7023bbcdb20f5999 (diff)
downloadscummvm-rg350-3fc592df497b957b42aa4eec27f8f77f899e0700.tar.gz
scummvm-rg350-3fc592df497b957b42aa4eec27f8f77f899e0700.tar.bz2
scummvm-rg350-3fc592df497b957b42aa4eec27f8f77f899e0700.zip
ILLUSIONS: Add Control::calcPosition and Control::readPointsConfig
-rw-r--r--engines/illusions/actor.cpp55
-rw-r--r--engines/illusions/actor.h3
-rw-r--r--engines/illusions/actorresource.cpp6
-rw-r--r--engines/illusions/actorresource.h4
-rw-r--r--engines/illusions/illusions.cpp10
5 files changed, 64 insertions, 14 deletions
diff --git a/engines/illusions/actor.cpp b/engines/illusions/actor.cpp
index 01222f3ee5..c0a42a1432 100644
--- a/engines/illusions/actor.cpp
+++ b/engines/illusions/actor.cpp
@@ -284,6 +284,26 @@ void Control::deactivateObject() {
}
}
+void Control::readPointsConfig(byte *pointsConfig) {
+ _unkPt.x = READ_LE_UINT16(pointsConfig + 0);
+ _unkPt.y = READ_LE_UINT16(pointsConfig + 2);
+ pointsConfig += 2;
+ _pt.x = READ_LE_UINT16(pointsConfig + 0);
+ _pt.y = READ_LE_UINT16(pointsConfig + 2);
+ pointsConfig += 2;
+ _feetPt.x = READ_LE_UINT16(pointsConfig + 0);
+ _feetPt.y = READ_LE_UINT16(pointsConfig + 2);
+ pointsConfig += 2;
+ _position.x = READ_LE_UINT16(pointsConfig + 0);
+ _position.y = READ_LE_UINT16(pointsConfig + 2);
+ pointsConfig += 2;
+ for (uint i = 0; i < kSubObjectsCount; ++i) {
+ _subobjectsPos[i].x = READ_LE_UINT16(pointsConfig + 0);
+ _subobjectsPos[i].y = READ_LE_UINT16(pointsConfig + 2);
+ pointsConfig += 2;
+ }
+}
+
void Control::setActorPosition(Common::Point position) {
_actor->_position = position;
}
@@ -377,6 +397,35 @@ int Control::getPriority() {
return p + 50 * ((objectId & 0x3F) + ((10000 * priority + positionY + 5000) << 6));
}
+Common::Point Control::calcPosition(Common::Point posDelta) {
+ Common::Point pos;
+ if (_actor->_parentObjectId) {
+ int16 accuX = 0, accuY = 0;
+ Actor *actor = _actor;
+ while (actor->_parentObjectId) {
+ Control *parentControl = _vm->_dict->getObjectControl(actor->_parentObjectId);
+ accuX += parentControl->_subobjectsPos[actor->_linkIndex - 1].x;
+ accuY += parentControl->_subobjectsPos[actor->_linkIndex - 1].y;
+ actor = parentControl->_actor;
+ }
+ pos = actor->_position;
+ pos.x += accuX * actor->_scale / 100;
+ pos.y += accuY * actor->_scale / 100;
+ _actor->_position = pos;
+ if (!(_actor->_flags & 8)) {
+ pos.x -= posDelta.x;
+ pos.y -= posDelta.y;
+ }
+ } else {
+ pos = _actor->_position;
+ if (!(_actor->_flags & 8)) {
+ pos.x -= posDelta.x;
+ pos.y -= posDelta.y;
+ }
+ }
+ return pos;
+}
+
uint32 Control::getSubActorParent() {
uint32 parentObjectId = _objectId;
while (1) {
@@ -400,7 +449,7 @@ void Control::getCollisionRectAccurate(Common::Rect &collisionRect) {
}
if (_actor) {
- if (_actor->_scale != 100 ) {
+ if (_actor->_scale != 100) {
// scaledValue = value * scale div 100
collisionRect.left = collisionRect.left * _actor->_scale / 100;
collisionRect.top = collisionRect.top * _actor->_scale / 100;
@@ -429,7 +478,7 @@ void Control::setActorFrameIndex(int16 frameIndex) {
_actor->_frameIndex = frameIndex;
const Frame &frame = (*_actor->_frames)[frameIndex - 1];
_actor->_surfInfo = frame._surfInfo;
- // TODO memcpy(&control->unkPt, (const void *)frame->config, 0x4Cu);
+ readPointsConfig(frame._pointsConfig);
_actor->_flags |= 0x2000;
_actor->_flags |= 0x4000;
_actor->_newFrameIndex = 0;
@@ -535,7 +584,7 @@ void Controls::placeActor(uint32 actorTypeId, Common::Point placePt, uint32 sequ
control->_flags = actorType->_flags;
control->_priority = actorType->_priority;
control->_objectId = objectId;
- // TODO memcpy(&control->unkPt, (const void *)actorType->_config, 0x4Cu);
+ control->readPointsConfig(actorType->_pointsConfig);
control->_actorTypeId = actorTypeId;
control->_actor = actor;
/* TODO
diff --git a/engines/illusions/actor.h b/engines/illusions/actor.h
index abe746dc9d..d913710c14 100644
--- a/engines/illusions/actor.h
+++ b/engines/illusions/actor.h
@@ -138,6 +138,7 @@ public:
bool isActorVisible();
void activateObject();
void deactivateObject();
+ void readPointsConfig(byte *pointsConfig);
void setActorPosition(Common::Point position);
Common::Point getActorPosition();
void setActorScale(int scale);
@@ -148,6 +149,7 @@ public:
void clearNotifyThreadId2();
void setPriority(int16 priority);
int getPriority();
+ Common::Point calcPosition(Common::Point posDelta);
uint32 getSubActorParent();
void getCollisionRectAccurate(Common::Rect &collisionRect);
void setActorUsePan(int usePan);
@@ -171,6 +173,7 @@ public:
Common::Point _pt;
Common::Point _feetPt;
Common::Point _position;
+ Common::Point _subobjectsPos[kSubObjectsCount];
// TODO 0000001C - 00000054 unknown
void startSequenceActorIntern(uint32 sequenceId, int value, int value2, uint32 notifyThreadId);
};
diff --git a/engines/illusions/actorresource.cpp b/engines/illusions/actorresource.cpp
index 541e4b4aed..426fff653d 100644
--- a/engines/illusions/actorresource.cpp
+++ b/engines/illusions/actorresource.cpp
@@ -77,10 +77,11 @@ bool ActorResourceLoader::isFlag(int flag) {
void Frame::load(byte *dataStart, Common::SeekableReadStream &stream) {
_flags = stream.readUint16LE();
stream.skip(2); // Skip padding
- stream.readUint32LE(); // TODO config dd
+ uint32 pointsConfigOffs = stream.readUint32LE();
_surfInfo.load(stream);
uint32 compressedPixelsOffs = stream.readUint32LE();
_compressedPixels = dataStart + compressedPixelsOffs;
+ _pointsConfig = dataStart + pointsConfigOffs;
debug(5, "Frame::load() compressedPixelsOffs: %08X",
compressedPixelsOffs);
@@ -99,7 +100,7 @@ void Sequence::load(byte *dataStart, Common::SeekableReadStream &stream) {
void ActorType::load(byte *dataStart, Common::SeekableReadStream &stream) {
_actorTypeId = stream.readUint32LE();
_surfInfo.load(stream);
- stream.readUint32LE(); // TODO config dd
+ uint32 pointsConfigOffs = stream.readUint32LE();
stream.readUint16LE(); // TODO namedPointsCount dw
stream.skip(2); // Skip padding
stream.readUint32LE(); // TODO namedPoints dd
@@ -116,6 +117,7 @@ void ActorType::load(byte *dataStart, Common::SeekableReadStream &stream) {
_priorityLayerIndex = stream.readUint16LE();
_regionLayerIndex = stream.readUint16LE();
_flags = stream.readUint16LE();
+ _pointsConfig = dataStart + pointsConfigOffs;
debug(5, "ActorType::load() _actorTypeId: %08X; _color(%d,%d,%d); _scale: %d; _priority: %d; _value1E: %d",
_actorTypeId, _color.r, _color.g, _color.b, _scale, _priority, _value1E);
diff --git a/engines/illusions/actorresource.h b/engines/illusions/actorresource.h
index 1b6e271a16..b15f3a0670 100644
--- a/engines/illusions/actorresource.h
+++ b/engines/illusions/actorresource.h
@@ -45,7 +45,7 @@ protected:
struct Frame {
uint16 _flags;
- // TODO config dd
+ byte *_pointsConfig;
SurfInfo _surfInfo;
byte *_compressedPixels;
void load(byte *dataStart, Common::SeekableReadStream &stream);
@@ -61,7 +61,7 @@ struct Sequence {
struct ActorType {
uint32 _actorTypeId;
SurfInfo _surfInfo;
- // TODO config dd
+ byte *_pointsConfig;
// TODO namedPointsCount dw
// TODO namedPoints dd
RGB _color;
diff --git a/engines/illusions/illusions.cpp b/engines/illusions/illusions.cpp
index 3d182276e0..ddb4d6039e 100644
--- a/engines/illusions/illusions.cpp
+++ b/engines/illusions/illusions.cpp
@@ -136,20 +136,16 @@ Common::Error IllusionsEngine::run() {
// Actor/graphics test
_resSys->loadResource(0x00110007, 0, 0);
_resSys->loadResource(0x00100006, 0, 0);
-
_controls->placeActor(0x00050008, Common::Point(200, 200), 0x00060136, 0x00040001, 0);
-
Control *control = *_controls->_controls.begin();
control->setActorFrameIndex(1);
control->appearActor();
-
+ //_camera->panToPoint(Common::Point(800, 0), 500, 0);
while (!shouldQuit()) {
updateGraphics();
_screen->updateSprites();
_system->updateScreen();
updateEvents();
-
- //break;
}
#endif
@@ -268,8 +264,8 @@ int IllusionsEngine::updateGraphics() {
debug("control->_pauseCtr: %d; actor->_flags: %04X", control->_pauseCtr, actor->_flags);
if (control->_pauseCtr == 0 && actor && (actor->_flags & 1) && !(actor->_flags & 0x0200)) {
- // TODO Common::Point drawPosition = control->calcPosition(panPoint);
- Common::Point drawPosition(200, 200);//DEBUG
+ Common::Point drawPosition = control->calcPosition(panPoint);
+ debug("drawPosition: %d, %d", drawPosition.x, drawPosition.y);
if (actor->_flags & 0x2000) {
Frame *frame = &(*actor->_frames)[actor->_frameIndex - 1];
_screen->_decompressQueue->insert(&actor->_drawFlags, frame->_flags,