aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/illusions/actor.cpp13
-rw-r--r--engines/illusions/actor.h3
-rw-r--r--engines/illusions/actorresource.cpp7
-rw-r--r--engines/illusions/actorresource.h3
-rw-r--r--engines/illusions/backgroundresource.cpp4
-rw-r--r--engines/illusions/camera.cpp43
-rw-r--r--engines/illusions/fixedpoint.cpp6
-rw-r--r--engines/illusions/illusions.cpp12
-rw-r--r--engines/illusions/time.cpp10
-rw-r--r--engines/illusions/time.h1
10 files changed, 80 insertions, 22 deletions
diff --git a/engines/illusions/actor.cpp b/engines/illusions/actor.cpp
index 9f5975fb16..ee4f677187 100644
--- a/engines/illusions/actor.cpp
+++ b/engines/illusions/actor.cpp
@@ -22,7 +22,6 @@
#include "illusions/illusions.h"
#include "illusions/actor.h"
-#include "illusions/actorresource.h"
#include "illusions/camera.h"
#include "illusions/input.h"
@@ -337,4 +336,16 @@ void Control::setActorUsePan(int usePan) {
_flags |= 8;
}
+void Control::setActorFrameIndex(int16 frameIndex) {
+ if (frameIndex) {
+ _actor->_frameIndex = frameIndex;
+ const Frame &frame = _actor->_frames[frameIndex - 1];
+ _actor->_surfInfo = frame._surfInfo;
+ // TODO memcpy(&control->unkPt, (const void *)frame->config, 0x4Cu);
+ _actor->_flags |= 0x2000;
+ _actor->_flags |= 0x4000;
+ _actor->_newFrameIndex = 0;
+ }
+}
+
} // End of namespace Illusions
diff --git a/engines/illusions/actor.h b/engines/illusions/actor.h
index 43e7ef4959..3dc87e2296 100644
--- a/engines/illusions/actor.h
+++ b/engines/illusions/actor.h
@@ -23,6 +23,7 @@
#ifndef ILLUSIONS_ACTOR_H
#define ILLUSIONS_ACTOR_H
+#include "illusions/actorresource.h"
#include "illusions/graphics.h"
#include "common/algorithm.h"
#include "graphics/surface.h"
@@ -77,6 +78,7 @@ public:
int16 _newFrameIndex;
SurfInfo _surfInfo;
Graphics::Surface *_surface;
+ Frame *_frames;
Common::Point _position;
uint _facing;
@@ -121,6 +123,7 @@ public:
uint32 getSubActorParent();
void getCollisionRectAccurate(Common::Rect &collisionRect);
void setActorUsePan(int usePan);
+ void setActorFrameIndex(int16 frameIndex);
public:
IllusionsEngine *_vm;
uint _flags;
diff --git a/engines/illusions/actorresource.cpp b/engines/illusions/actorresource.cpp
index 59123bb2db..e200fae532 100644
--- a/engines/illusions/actorresource.cpp
+++ b/engines/illusions/actorresource.cpp
@@ -77,13 +77,12 @@ bool ActorResourceLoader::isFlag(int flag) {
void Frame::load(byte *dataStart, Common::SeekableReadStream &stream) {
stream.readUint32LE(); //field_0 dd
stream.readUint32LE(); // TODO config dd
- _pixelSize = stream.readUint32LE();
- _dimensions.load(stream);
+ _surfInfo.load(stream);
uint32 compressedPixelsOffs = stream.readUint32LE();
_compressedPixels = dataStart + compressedPixelsOffs;
- debug("Frame::load() _pixelSize: %d; compressedPixelsOffs: %08X",
- _pixelSize, compressedPixelsOffs);
+ debug("Frame::load() compressedPixelsOffs: %08X",
+ compressedPixelsOffs);
}
void Sequence::load(byte *dataStart, Common::SeekableReadStream &stream) {
diff --git a/engines/illusions/actorresource.h b/engines/illusions/actorresource.h
index 196d72d063..78ce89ae4d 100644
--- a/engines/illusions/actorresource.h
+++ b/engines/illusions/actorresource.h
@@ -46,8 +46,7 @@ protected:
struct Frame {
//field_0 dd
// TODO config dd
- uint32 _pixelSize;
- WidthHeight _dimensions;
+ SurfInfo _surfInfo;
byte *_compressedPixels;
void load(byte *dataStart, Common::SeekableReadStream &stream);
};
diff --git a/engines/illusions/backgroundresource.cpp b/engines/illusions/backgroundresource.cpp
index 89f91655f0..aef2a4ca9e 100644
--- a/engines/illusions/backgroundresource.cpp
+++ b/engines/illusions/backgroundresource.cpp
@@ -46,8 +46,8 @@ void BackgroundResourceLoader::load(Resource *resource) {
// TODO Insert IDs from item48s
// TODO camera_fadeClear();
- // TODO bgInfo = &bgResourceb->bgInfos[(unsigned __int16)BgResource_findMasterBgIndex(bgResourceb)];
- // TODO camera_set(bgInfo[-1].panPoint, bgInfo[-1].surfInfo.dimensions);
+ int index = backgroundItem->_bgRes->findMasterBgIndex();
+ _vm->_camera->set(backgroundItem->_bgRes->_bgInfos[index - 1]._panPoint, backgroundItem->_bgRes->_bgInfos[index - 1]._surfInfo._dimensions);
// NOTE Skipped palette loading (not used in BBDOU)
}
diff --git a/engines/illusions/camera.cpp b/engines/illusions/camera.cpp
index d81c746274..fceb6b6341 100644
--- a/engines/illusions/camera.cpp
+++ b/engines/illusions/camera.cpp
@@ -121,7 +121,7 @@ void Camera::panToPoint(Common::Point pt, int16 panSpeed, uint32 panNotifyId) {
_activeState._panNotifyId = 0;
}
- _activeState._panTargetPoint = Camera::getPtOffset(pt);
+ _activeState._panTargetPoint = getPtOffset(pt);
clipPanTargetPoint();
if (panSpeed) {
@@ -136,7 +136,7 @@ void Camera::panToPoint(Common::Point pt, int16 panSpeed, uint32 panNotifyId) {
recalcPan(_activeState._panStartTime);
} else {
_activeState._currPan = _activeState._panTargetPoint;
- // TODO stopPan();
+ stopPan();
if (panNotifyId) {
// TODO scrmgrNotifyID(panNotifyId);
}
@@ -193,15 +193,15 @@ void Camera::pushCameraMode() {
item._panTargetPoint.x = 0;
item._panTargetPoint.y = 0;
switch (_activeState._cameraMode) {
- case 4:
- item._cameraMode = 3;
- item._panObjectId = _activeState._panObjectId;
- break;
case 1:
case 2:
case 3:
item._panObjectId = _activeState._panObjectId;
break;
+ case 4:
+ item._cameraMode = 3;
+ item._panObjectId = _activeState._panObjectId;
+ break;
case 5:
item._panTargetPoint = _activeState._panTargetPoint;
item._panNotifyId = _activeState._panNotifyId;
@@ -248,6 +248,8 @@ void Camera::update(uint32 currTime) {
if (_activeState._paused)
return;
+ //debug("_activeState._cameraMode = %d", _activeState._cameraMode);
+
switch (_activeState._cameraMode) {
case 1:
updateMode1(currTime);
@@ -402,14 +404,23 @@ void Camera::updateMode3(uint32 currTime) {
bool Camera::updatePan(uint32 currTime) {
if (currTime - _activeState._time28 >= _activeState._time2E) {
+debug("#1 updatePan");
_activeState._panXShl = _activeState._panTargetPoint.x << 16;
_activeState._panYShl = _activeState._panTargetPoint.y << 16;
} else {
+debug("#2 updatePan");
+debug("_activeState._someX = %d", _activeState._someX);
+debug("1) _activeState._panXShl = %08X", _activeState._panXShl);
+debug("currTime - _activeState._panStartTime = %d", currTime - _activeState._panStartTime);
_activeState._panXShl += fixedMul(_activeState._someX, (currTime - _activeState._panStartTime) << 16);
_activeState._panYShl += fixedMul(_activeState._someY, (currTime - _activeState._panStartTime) << 16);
+debug("2) _activeState._panXShl = %08X", _activeState._panXShl);
}
_activeState._panStartTime = currTime;
Common::Point newPan(_activeState._panXShl >> 16, _activeState._panYShl >> 16);
+
+ debug("newPan = %d, %d", newPan.x, newPan.y);
+
if (_activeState._currPan.x != newPan.x || _activeState._currPan.y != newPan.y) {
_activeState._currPan = newPan;
return true;
@@ -439,13 +450,24 @@ void Camera::recalcPan(uint32 currTime) {
FP16 x2 = _activeState._panTargetPoint.x << 16;
FP16 y2 = _activeState._panTargetPoint.y << 16;
FP16 distance = fixedDistance(x1, y1, x2, y2);
+
+ debug("(%08X, %08X), (%08X, %08X) %08X", x1, y1, x2, y2, distance);
+
_activeState._time2E = 60 * fixedTrunc(distance) / _activeState._panSpeed;
+
+ debug("_activeState._time2E = %d", _activeState._time2E);
+
}
if (_activeState._time2E != 0) {
+debug("#1 recalcPan");
+debug("_activeState._panTargetPoint.x = %d; _activeState._currPan2.x = %d", _activeState._panTargetPoint.x, _activeState._currPan2.x);
+debug("_activeState._panTargetPoint.x - _activeState._currPan2.x = %d", _activeState._panTargetPoint.x - _activeState._currPan2.x);
+debug("_activeState._time2E = %d", _activeState._time2E);
_activeState._someX = fixedDiv((_activeState._panTargetPoint.x - _activeState._currPan2.x) << 16, _activeState._time2E << 16);
_activeState._someY = fixedDiv((_activeState._panTargetPoint.y - _activeState._currPan2.y) << 16, _activeState._time2E << 16);
} else {
+debug("#2 recalcPan");
_activeState._someX = (_activeState._panTargetPoint.x - _activeState._currPan2.x) << 16;
_activeState._someY = (_activeState._panTargetPoint.y - _activeState._currPan2.y) << 16;
}
@@ -472,10 +494,19 @@ bool Camera::calcPointFlags(Common::Point &pt, WRect &rect, uint &outFlags) {
}
void Camera::clipPanTargetPoint() {
+
+ debug("clip in (%d, %d)", _activeState._panTargetPoint.x, _activeState._panTargetPoint.y);
+
_activeState._panTargetPoint.x = CLIP(_activeState._panTargetPoint.x,
_activeState._bounds._topLeft.x, _activeState._bounds._bottomRight.x);
_activeState._panTargetPoint.y = CLIP(_activeState._panTargetPoint.y,
_activeState._bounds._topLeft.y, _activeState._bounds._bottomRight.y);
+
+ debug("clip rect (%d, %d, %d, %d)", _activeState._bounds._topLeft.x, _activeState._bounds._topLeft.y,
+ _activeState._bounds._bottomRight.x, _activeState._bounds._bottomRight.y);
+
+ debug("clip out (%d, %d)", _activeState._panTargetPoint.x, _activeState._panTargetPoint.y);
+
}
} // End of namespace Illusions
diff --git a/engines/illusions/fixedpoint.cpp b/engines/illusions/fixedpoint.cpp
index ee3818d10a..7fc15e424e 100644
--- a/engines/illusions/fixedpoint.cpp
+++ b/engines/illusions/fixedpoint.cpp
@@ -34,13 +34,11 @@ float fixedToFloat(FP16 value) {
}
FP16 fixedMul(FP16 a, FP16 b) {
- // CHECKME Not sure if this correct
- return (a * b) >> 16;
+ return ((float)a * b) / 65536.0;
}
FP16 fixedDiv(FP16 a, FP16 b) {
- // CHECKME Not sure if this correct
- return (a << 16) / b;
+ return ((float)a / b) * 65536.0;
}
int fixedTrunc(FP16 value) {
diff --git a/engines/illusions/illusions.cpp b/engines/illusions/illusions.cpp
index 2b44141537..3e1758ddc2 100644
--- a/engines/illusions/illusions.cpp
+++ b/engines/illusions/illusions.cpp
@@ -34,6 +34,7 @@
#include "illusions/thread.h"
#include "illusions/scriptresource.h"
#include "illusions/scriptman.h"
+#include "illusions/time.h"
#include "audio/audiostream.h"
#include "common/config-manager.h"
@@ -99,11 +100,20 @@ Common::Error IllusionsEngine::run() {
#if 1
// BackgroundResource test
- _resSys->loadResource(0x0011001C, 0, 0);
+ _resSys->loadResource(0x00110007, 0, 0);
BackgroundItem *backgroundItem = _backgroundItems->debugFirst();
_system->copyRectToScreen((byte*)backgroundItem->_surfaces[0]->getBasePtr(0, 0), backgroundItem->_surfaces[0]->pitch, 0, 0, 640, 480);
_system->updateScreen();
+ _camera->panToPoint(Common::Point(800, 0), 500, 0);
while (!shouldQuit()) {
+ //debug("panPoints[0] = %d, %d", backgroundItem->_panPoints[0].x, backgroundItem->_panPoints[0].y);
+ uint32 t = getCurrentTime();
+ //debug("t = %d", t);
+ _camera->update(t);
+ _system->delayMillis(10);
+ _system->copyRectToScreen((byte*)backgroundItem->_surfaces[0]->getBasePtr(backgroundItem->_panPoints[0].x, 0),
+ backgroundItem->_surfaces[0]->pitch, 0, 0, 640, 480);
+ _system->updateScreen();
updateEvents();
}
#endif
diff --git a/engines/illusions/time.cpp b/engines/illusions/time.cpp
index 7873db6ba4..f190035b10 100644
--- a/engines/illusions/time.cpp
+++ b/engines/illusions/time.cpp
@@ -26,8 +26,14 @@
namespace Illusions {
uint32 getCurrentTime() {
- // TODO, move to own file with other time related code
- return g_system->getMillis();
+ return g_system->getMillis() / 60;
+}
+
+bool isTimerExpired(uint32 startTime, uint32 endTime) {
+ uint32 currTime = getCurrentTime();
+ return !(
+ (startTime > endTime && (currTime <= endTime || currTime >= startTime)) ||
+ (startTime < endTime && currTime <= endTime && currTime >= startTime));
}
} // End of namespace Illusions
diff --git a/engines/illusions/time.h b/engines/illusions/time.h
index 3083af2e73..c09b43628e 100644
--- a/engines/illusions/time.h
+++ b/engines/illusions/time.h
@@ -28,6 +28,7 @@
namespace Illusions {
uint32 getCurrentTime();
+bool isTimerExpired(uint32 startTime, uint32 endTime);
} // End of namespace Illusions