ILLUSIONS: Add Control::calcPosition and Control::readPointsConfig

This commit is contained in:
johndoe123 2014-03-18 16:00:51 +01:00 committed by Eugene Sandulenko
parent b3b0bd884d
commit 3fc592df49
5 changed files with 64 additions and 14 deletions

View File

@ -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) {
@ -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

View File

@ -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);
};

View File

@ -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);

View File

@ -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;

View File

@ -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,