aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Fry2018-05-25 21:51:21 +1000
committerEugene Sandulenko2018-07-20 06:43:33 +0000
commitbdc477bef9d4ec9691e77c4de867a30d08865c46 (patch)
tree6f32addc60b63768cede07d53aad234a73e5a694
parent7c46d891c6acc414e69c5cf624f45b7b297fe584 (diff)
downloadscummvm-rg350-bdc477bef9d4ec9691e77c4de867a30d08865c46.tar.gz
scummvm-rg350-bdc477bef9d4ec9691e77c4de867a30d08865c46.tar.bz2
scummvm-rg350-bdc477bef9d4ec9691e77c4de867a30d08865c46.zip
ILLUSIONS: Implement convertPanXCoord() to support audio panning.
Wire up startScriptThread2() calls. Add namedpoint logic.
-rw-r--r--engines/illusions/actor.cpp2
-rw-r--r--engines/illusions/duckman/duckman_specialcode.cpp3
-rw-r--r--engines/illusions/duckman/illusions_duckman.cpp77
-rw-r--r--engines/illusions/duckman/illusions_duckman.h1
-rw-r--r--engines/illusions/duckman/scriptopcodes_duckman.cpp4
-rw-r--r--engines/illusions/illusions.cpp15
-rw-r--r--engines/illusions/pathfinder.cpp17
-rw-r--r--engines/illusions/pathfinder.h3
-rw-r--r--engines/illusions/thread.cpp2
9 files changed, 109 insertions, 15 deletions
diff --git a/engines/illusions/actor.cpp b/engines/illusions/actor.cpp
index e9aad26ce8..cb9f3a909d 100644
--- a/engines/illusions/actor.cpp
+++ b/engines/illusions/actor.cpp
@@ -770,7 +770,7 @@ PointArray *Control::createPath(Common::Point destPt) {
PathLines *walkRects = (_actor->_flags & Illusions::ACTOR_FLAG_HAS_WALK_RECTS) ? _actor->_pathWalkRects->_rects : 0;
PathFinder pathFinder;
WidthHeight bgDimensions = _vm->_backgroundInstances->getMasterBgDimensions();
- PointArray *path = pathFinder.findPath(_actor->_position, destPt, walkPoints, walkRects, bgDimensions);
+ PointArray *path = pathFinder.findPath(_vm->_camera, _actor->_position, destPt, walkPoints, walkRects, bgDimensions);
for (uint i = 0; i < path->size(); ++i) {
//debug(0, "Path(%d) (%d, %d)", i, (*path)[i].x, (*path)[i].y);
}
diff --git a/engines/illusions/duckman/duckman_specialcode.cpp b/engines/illusions/duckman/duckman_specialcode.cpp
index d53896d6ac..60e05052c0 100644
--- a/engines/illusions/duckman/duckman_specialcode.cpp
+++ b/engines/illusions/duckman/duckman_specialcode.cpp
@@ -103,6 +103,7 @@ void DuckmanSpecialCode::run(uint32 specialCodeId, OpCall &opCall) {
} else {
debug("DuckmanSpecialCode::run() Unimplemented special code %08X", specialCodeId);
_vm->notifyThreadId(opCall._threadId);
+ error("DuckmanSpecialCode::run() Unimplemented special code");
}
}
@@ -392,7 +393,7 @@ void DuckmanSpecialCode::updateTeleporterProperties() {
_vm->_scriptResource->_properties.set(0x000E0075, _teleporterPosition.x == 4 && _teleporterPosition.y == 3);
_vm->_scriptResource->_properties.set(0x000E0076, _teleporterPosition.x == 3 && _teleporterPosition.y == 3);
_vm->_scriptResource->_properties.set(0x000E0077, _teleporterPosition.x == 2 && _teleporterPosition.y == 2);
- _vm->_scriptResource->_properties.set(0x000E0078, _teleporterPosition.x == 1 && _teleporterPosition.y == 1);
+ _vm->_scriptResource->_properties.set(0x000E0078, _teleporterPosition.x == 1 && _teleporterPosition.y == 1);
}
} // End of namespace Illusions
diff --git a/engines/illusions/duckman/illusions_duckman.cpp b/engines/illusions/duckman/illusions_duckman.cpp
index 9407812c99..325b6dca87 100644
--- a/engines/illusions/duckman/illusions_duckman.cpp
+++ b/engines/illusions/duckman/illusions_duckman.cpp
@@ -261,10 +261,10 @@ void IllusionsEngine_Duckman::initInput() {
_input->setInputEvent(kEventDown, 0x80)
.addMouseButton(MOUSE_RIGHT_BUTTON)
.addKey(Common::KEYCODE_DOWN);
- /* Not implemented, used for original debugging purposes
+#if 1 //TODO hide behind "gosanta" code
_input->setInputEvent(kEventF1, 0x100)
.addKey(Common::KEYCODE_F1);
- */
+#endif
}
#define UPDATEFUNCTION(priority, sceneId, callback) \
@@ -294,6 +294,8 @@ int IllusionsEngine_Duckman::updateScript(uint flags) {
}
_threads->updateThreads();
+
+ //TODO need to call startScriptThread2(0x10002, 0x20001, 0);
return kUFNext;
}
@@ -459,6 +461,22 @@ Control *IllusionsEngine_Duckman::getObjectControl(uint32 objectId) {
return _dict->getObjectControl(objectId);
}
+static const uint8 kPointConversionTable[] = {
+ 0, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
+ 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
+ 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
+ 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
+ 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
+ 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
+ 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
+ 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 1, 2, 3,
+ 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 35,
+ 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
+ 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
+ 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
+ 35, 35, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
+ 33, 34
+};
Common::Point IllusionsEngine_Duckman::getNamedPointPosition(uint32 namedPointId) {
Common::Point pt;
Common::Point currPan = _camera->getCurrentPan();
@@ -471,8 +489,50 @@ Common::Point IllusionsEngine_Duckman::getNamedPointPosition(uint32 namedPointId
return currPan;
}
} else {
- // TODO
- debug(1, "getNamedPointPosition(%08X) UNKNOWN", namedPointId);
+ debug(1, "getNamedPointPosition(%02d)", kPointConversionTable[namedPointId - 0x00070001]);
+ switch(kPointConversionTable[namedPointId - 0x00070001]) {
+ case 0 : return Common::Point(160, 100);
+ case 1 : return currPan;
+ case 2 : return Common::Point(currPan.x - 160, currPan.y);
+ case 3 : return Common::Point(currPan.x + 160, currPan.y);
+ case 4 : return Common::Point(currPan.x, currPan.y - 100);
+ case 5 : return Common::Point(currPan.x, currPan.y + 100);
+ case 6 : return Common::Point(currPan.x - 160, currPan.y - 100);
+ case 7 : return Common::Point((uint16)(currPan.x + 160), currPan.y - 100);
+ case 8 : return Common::Point(currPan.x - 160, currPan.y + 100);
+ case 9 : return Common::Point(currPan.x + 160, currPan.y + 100);
+ /* TODO implement these
+ case 10 : return Common::Point(0, 0);
+ case 11 : return Common::Point(0, 0);
+ case 12 : return Common::Point(0, 0);
+ case 13 : return Common::Point(0, 0);
+ case 14 : return Common::Point(0, 0);
+ */
+ case 15 : return Common::Point(0, 0);
+ /* TODO implement these
+ case 16 : return Common::Point(0, 0);
+ case 17 : return Common::Point(0, 0);
+ case 18 : return Common::Point(0, 0);
+ */
+ case 19 : return Common::Point(0, 0);
+ case 20 : return Common::Point(320, 0);
+ case 21 : return Common::Point(640, 0);
+ case 22 : return Common::Point(960, 0);
+ case 23 : return Common::Point(0, 200);
+ case 24 : return Common::Point(320, 200);
+ case 25 : return Common::Point(640, 200);
+ case 26 : return Common::Point(960, 200);
+ case 27 : return Common::Point(0, 400);
+ case 28 : return Common::Point(320, 400);
+ case 29 : return Common::Point(640, 400);
+ case 30 : return Common::Point(960, 400);
+ case 31 : return Common::Point(0, 600);
+ case 32 : return Common::Point(320, 0);
+ case 33 : return Common::Point(640, 0);
+ case 34 : return Common::Point(960, 0);
+ default : break;
+ }
+ error("getNamedPointPosition(%02d) UNKNOWN", kPointConversionTable[namedPointId - 0x00070001]);
return Common::Point(0, 0);
}
}
@@ -717,6 +777,13 @@ void IllusionsEngine_Duckman::startScriptThread(uint32 threadId, uint32 callingT
newScriptThread(threadId, callingThreadId, 0, scriptCodeIp);
}
+void IllusionsEngine_Duckman::startScriptThread2(uint32 sceneId, uint32 threadId, uint32 callingThreadId) {
+ debug(2, "Starting script thread2");
+ _savegameSceneId = sceneId;
+ _savegameThreadId = threadId;
+ startScriptThread(0x20002, callingThreadId);
+}
+
uint32 IllusionsEngine_Duckman::startAbortableTimerThread(uint32 duration, uint32 threadId) {
return newTimerThread(duration, threadId, true);
}
@@ -824,7 +891,7 @@ bool IllusionsEngine_Duckman::enterScene(uint32 sceneId, uint32 threadId) {
startScriptThread(threadId, 0);
return true;
}
- // TODO startScriptThread2(0x10002, 0x20001, 0);
+ startScriptThread2(0x10002, 0x20001, 0);
return false;
}
diff --git a/engines/illusions/duckman/illusions_duckman.h b/engines/illusions/duckman/illusions_duckman.h
index daa1b06c0c..87ca932ea8 100644
--- a/engines/illusions/duckman/illusions_duckman.h
+++ b/engines/illusions/duckman/illusions_duckman.h
@@ -147,6 +147,7 @@ public:
void startScriptThreadSimple(uint32 threadId, uint32 callingThreadId);
void startScriptThread(uint32 threadId, uint32 callingThreadId);
+ void startScriptThread2(uint32 threadId, uint32 callingThreadId, uint32 unk);
uint32 startAbortableTimerThread(uint32 duration, uint32 threadId);
uint32 startTimerThread(uint32 duration, uint32 threadId);
uint32 startAbortableThread(byte *scriptCodeIp1, byte *scriptCodeIp2, uint32 callingThreadId);
diff --git a/engines/illusions/duckman/scriptopcodes_duckman.cpp b/engines/illusions/duckman/scriptopcodes_duckman.cpp
index 10efceae24..9ac0b9a0ad 100644
--- a/engines/illusions/duckman/scriptopcodes_duckman.cpp
+++ b/engines/illusions/duckman/scriptopcodes_duckman.cpp
@@ -321,7 +321,7 @@ void ScriptOpcodes_Duckman::opStartModalScene(ScriptThread *scriptThread, OpCall
void ScriptOpcodes_Duckman::opExitModalScene(ScriptThread *scriptThread, OpCall &opCall) {
_vm->_input->discardAllEvents();
if (_vm->_scriptResource->_properties.get(0x000E0027)) {
- // TODO _vm->startScriptThread2(0x10002, 0x20001, 0);
+ _vm->startScriptThread2(0x10002, 0x20001, 0);
opCall._result = kTSTerminate;
} else {
_vm->dumpCurrSceneFiles(_vm->getCurrentScene(), opCall._callerThreadId);
@@ -521,7 +521,7 @@ void ScriptOpcodes_Duckman::opAppearActor(ScriptThread *scriptThread, OpCall &op
ARG_UINT32(objectId);
Control *control = _vm->_dict->getObjectControl(objectId);
if (!control) {
- Common::Point pos = _vm->getNamedPointPosition(0x70001);
+ Common::Point pos = _vm->getNamedPointPosition(0x70001);
_vm->_controls->placeActor(0x50001, pos, 0x60001, objectId, 0);
control = _vm->_dict->getObjectControl(objectId);
}
diff --git a/engines/illusions/illusions.cpp b/engines/illusions/illusions.cpp
index 11ef6d0ac7..83881103a1 100644
--- a/engines/illusions/illusions.cpp
+++ b/engines/illusions/illusions.cpp
@@ -238,8 +238,19 @@ int IllusionsEngine::getRandom(int max) {
}
int IllusionsEngine::convertPanXCoord(int16 x) {
- // TODO
- return 0;
+ int16 diff = x - _camera->getCurrentPan().x;
+ int16 absX = ABS(diff);
+ int newX = 0;
+ if ( absX < 160) {
+ newX = (diff << 7) / 320;
+ } else if (diff < 0) {
+ newX = -64;
+ } else {
+ newX = 64;
+ }
+ debug(1, "convertPanXCoord %d %d -> %d", diff, x, newX);
+
+ return newX;
}
bool IllusionsEngine::calcPointDirection(Common::Point &srcPt, Common::Point &dstPt, uint &facing) {
diff --git a/engines/illusions/pathfinder.cpp b/engines/illusions/pathfinder.cpp
index 1e781e64ea..b0b43a0e4f 100644
--- a/engines/illusions/pathfinder.cpp
+++ b/engines/illusions/pathfinder.cpp
@@ -22,11 +22,16 @@
#include "illusions/illusions.h"
#include "illusions/pathfinder.h"
+#include "camera.h"
namespace Illusions {
-PointArray *PathFinder::findPath(Common::Point sourcePt, Common::Point destPt,
+PointArray *PathFinder::findPath(Camera *camera, Common::Point sourcePt, Common::Point destPt,
PointArray *walkPoints, PathLines *walkRects, WidthHeight bgDimensions) {
+ Common::Point cameraPt = camera->getScreenOffset();
+ _screenRect.p0 = cameraPt;
+ _screenRect.p1.x = cameraPt.x + 320; //TODO fix me get screen dimentions here.
+ _screenRect.p1.y = cameraPt.y + 200;
_walkPoints = walkPoints;
_walkRects = walkRects;
_bgDimensions = bgDimensions;
@@ -132,8 +137,16 @@ void PathFinder::findValidDestPt(Common::Point &destPt) {
int minDistance = 0xFFFF, currDistance;
PathLine destLine;
for (uint i = 0; i < _walkRects->size(); ++i) {
- PathLine &currRect = (*_walkRects)[i];
+ PathLine currRect = (*_walkRects)[i];
+ //TODO fix this hack. Used here to get xmas tree scene to work.
+ if(currRect.p1.x > _screenRect.p1.x) {
+ currRect.p1.x = _screenRect.p1.x;
+ }
+ if(currRect.p0.x < _screenRect.p0.x) {
+ currRect.p0.x = _screenRect.p0.x;
+ }
WidthHeight rectDimensions = calcRectDimensions(currRect);
+
adjustRectDimensions(rectDimensions);
clipLineToBg(destPt, rectDimensions, destLine);
if (calcLineStatus(destLine, currRect, &outPt) == 3) {
diff --git a/engines/illusions/pathfinder.h b/engines/illusions/pathfinder.h
index f337a25fc0..47cc0575c5 100644
--- a/engines/illusions/pathfinder.h
+++ b/engines/illusions/pathfinder.h
@@ -39,9 +39,10 @@ typedef Common::Array<Common::Point> PointArray;
class PathFinder {
public:
- PointArray *findPath(Common::Point sourcePt, Common::Point destPt,
+ PointArray *findPath(Camera *camera, Common::Point sourcePt, Common::Point destPt,
PointArray *walkPoints, PathLines *walkRects, WidthHeight bgDimensions);
protected:
+ PathLine _screenRect;
PointArray *_walkPoints;
PathLines *_walkRects;
WidthHeight _bgDimensions;
diff --git a/engines/illusions/thread.cpp b/engines/illusions/thread.cpp
index b7ea41b53a..d984af2c67 100644
--- a/engines/illusions/thread.cpp
+++ b/engines/illusions/thread.cpp
@@ -160,7 +160,7 @@ void ThreadList::updateThreads() {
if (_vm->_rerunThreads)
_vm->_rerunThreads = false;
else
- break;
+ break;
}
}