aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Kiewitz2010-09-03 22:15:08 +0000
committerMartin Kiewitz2010-09-03 22:15:08 +0000
commite4c07925ecde598507c27b5be5a373bf333e70dd (patch)
treec32e822b02c4521f77a93721d5468d430f69f1f8
parent8a168f028bfdf084892abd623942a0c3f9f8de58 (diff)
downloadscummvm-rg350-e4c07925ecde598507c27b5be5a373bf333e70dd.tar.gz
scummvm-rg350-e4c07925ecde598507c27b5be5a373bf333e70dd.tar.bz2
scummvm-rg350-e4c07925ecde598507c27b5be5a373bf333e70dd.zip
SCI: kDirLoop freshly reversed
svn-id: r52510
-rw-r--r--engines/sci/engine/kgraphics.cpp59
-rw-r--r--engines/sci/engine/kmovement.cpp4
2 files changed, 29 insertions, 34 deletions
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index e19a51b525..a3d51b5c55 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -62,48 +62,43 @@ void showScummVMDialog(const Common::String &message) {
dialog.runModal();
}
-void _k_dirloop(reg_t object, uint16 angle, EngineState *s, int argc, reg_t *argv) {
+void kDirLoopWorker(reg_t object, uint16 angle, EngineState *s, int argc, reg_t *argv) {
GuiResourceId viewId = readSelectorValue(s->_segMan, object, SELECTOR(view));
uint16 signal = readSelectorValue(s->_segMan, object, SELECTOR(signal));
- int16 loopNo;
- int16 maxLoops;
- bool oldScriptHeader = (getSciVersion() == SCI_VERSION_0_EARLY);
if (signal & kSignalDoesntTurn)
return;
angle %= 360;
- if (!oldScriptHeader) {
- if (angle < 45)
- loopNo = 3;
- else if (angle < 136)
- loopNo = 0;
- else if (angle < 225)
- loopNo = 2;
- else if (angle < 316)
- loopNo = 1;
- else
- loopNo = 3;
+ int16 useLoop = -1;
+ if (getSciVersion() > SCI_VERSION_0_EARLY) {
+ if ((angle > 315) || (angle < 45)) {
+ useLoop = 3;
+ } else if ((angle > 135) && (angle < 225)) {
+ useLoop = 2;
+ }
} else {
- if (angle >= 330 || angle <= 30)
- loopNo = 3;
- else if (angle <= 150)
- loopNo = 0;
- else if (angle <= 210)
- loopNo = 2;
- else if (angle < 330)
- loopNo = 1;
- else loopNo = -1;
+ // SCI0EARLY
+ if ((angle > 330) || (angle < 30)) {
+ useLoop = 3;
+ } else if ((angle > 150) && (angle < 210)) {
+ useLoop = 2;
+ }
+ }
+ if (useLoop == -1) {
+ if (angle >= 180) {
+ useLoop = 1;
+ } else {
+ useLoop = 0;
+ }
+ } else {
+ int16 loopCount = g_sci->_gfxCache->kernelViewGetLoopCount(viewId);
+ if (loopCount < 4)
+ return;
}
- maxLoops = g_sci->_gfxCache->kernelViewGetLoopCount(viewId);
-
-
- if ((loopNo > 1) && (maxLoops < 4))
- return;
-
- writeSelectorValue(s->_segMan, object, SELECTOR(loop), loopNo);
+ writeSelectorValue(s->_segMan, object, SELECTOR(loop), useLoop);
}
static reg_t kSetCursorSci0(EngineState *s, int argc, reg_t *argv) {
@@ -411,7 +406,7 @@ reg_t kPriCoord(EngineState *s, int argc, reg_t *argv) {
}
reg_t kDirLoop(EngineState *s, int argc, reg_t *argv) {
- _k_dirloop(argv[0], argv[1].toUint16(), s, argc, argv);
+ kDirLoopWorker(argv[0], argv[1].toUint16(), s, argc, argv);
return s->r_acc;
}
diff --git a/engines/sci/engine/kmovement.cpp b/engines/sci/engine/kmovement.cpp
index 5b64934133..7d26d10961 100644
--- a/engines/sci/engine/kmovement.cpp
+++ b/engines/sci/engine/kmovement.cpp
@@ -376,7 +376,7 @@ reg_t kDoBresen(EngineState *s, int argc, reg_t *argv) {
return s->r_acc;
}
-extern void _k_dirloop(reg_t obj, uint16 angle, EngineState *s, int argc, reg_t *argv);
+extern void kDirLoopWorker(reg_t obj, uint16 angle, EngineState *s, int argc, reg_t *argv);
int getAngle(int xrel, int yrel) {
if ((xrel == 0) && (yrel == 0))
@@ -503,7 +503,7 @@ reg_t kDoAvoider(EngineState *s, int argc, reg_t *argv) {
return s->r_acc;
} else {
// No looper? Fall back to DirLoop
- _k_dirloop(client, (uint16)angle, s, argc, argv);
+ kDirLoopWorker(client, (uint16)angle, s, argc, argv);
}
}