aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMax Horn2011-12-08 19:52:00 +0100
committerMax Horn2011-12-08 19:56:06 +0100
commit0d7815e9bbfb445d4cdd52a23695bbe5e874ceb4 (patch)
tree4460630bc8674c71ec9a9776a53f32b512368fa5 /engines
parente4e725fa8d251b1d8f986315dea25591bca88c96 (diff)
downloadscummvm-rg350-0d7815e9bbfb445d4cdd52a23695bbe5e874ceb4.tar.gz
scummvm-rg350-0d7815e9bbfb445d4cdd52a23695bbe5e874ceb4.tar.bz2
scummvm-rg350-0d7815e9bbfb445d4cdd52a23695bbe5e874ceb4.zip
DREAMWEB: Convert workoutFrames to C++
Diffstat (limited to 'engines')
-rw-r--r--engines/dreamweb/dreambase.h1
-rw-r--r--engines/dreamweb/dreamgen.cpp87
-rw-r--r--engines/dreamweb/dreamgen.h1
-rw-r--r--engines/dreamweb/pathfind.cpp55
4 files changed, 56 insertions, 88 deletions
diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h
index 28feb5b975..f52ada2a72 100644
--- a/engines/dreamweb/dreambase.h
+++ b/engines/dreamweb/dreambase.h
@@ -69,6 +69,7 @@ public:
Common::Point _lineData[200]; // Output of Bresenham
void checkDest(const RoomPaths *roomsPaths);
RoomPaths *getRoomsPaths();
+ void workoutFrames();
// from print.cpp
uint8 getNextWord(const Frame *charSet, const uint8 *string, uint8 *totalWidth, uint8 *charCount);
diff --git a/engines/dreamweb/dreamgen.cpp b/engines/dreamweb/dreamgen.cpp
index 3a9fb57541..209cabe107 100644
--- a/engines/dreamweb/dreamgen.cpp
+++ b/engines/dreamweb/dreamgen.cpp
@@ -6908,93 +6908,6 @@ searchmess:
printDirect();
}
-void DreamGenContext::workoutFrames() {
- STACK_CHECK;
- bx = data.word(kLinestartx);
- _add(bx, 32);
- ax = data.word(kLineendx);
- _add(ax, 32);
- _sub(bx, ax);
- if (!flags.c())
- goto notneg1;
- _neg(bx);
-notneg1:
- cx = data.word(kLinestarty);
- _add(cx, 32);
- ax = data.word(kLineendy);
- _add(ax, 32);
- _sub(cx, ax);
- if (!flags.c())
- goto notneg2;
- _neg(cx);
-notneg2:
- _cmp(bx, cx);
- if (!flags.c())
- goto tendstohoriz;
- dl = 2;
- ax = cx;
- _shr(ax, 1);
- _cmp(bx, ax);
- if (flags.c())
- goto gotquad;
- dl = 1;
- goto gotquad;
-tendstohoriz:
- dl = 0;
- ax = bx;
- _shr(ax, 1);
- _cmp(cx, ax);
- if (flags.c())
- goto gotquad;
- dl = 1;
- goto gotquad;
-gotquad:
- bx = data.word(kLinestartx);
- _add(bx, 32);
- ax = data.word(kLineendx);
- _add(ax, 32);
- _sub(bx, ax);
- if (flags.c())
- goto isinright;
- cx = data.word(kLinestarty);
- _add(cx, 32);
- ax = data.word(kLineendy);
- _add(ax, 32);
- _sub(cx, ax);
- if (!flags.c())
- goto topleft;
- _cmp(dl, 1);
- if (flags.z())
- goto noswap1;
- _xor(dl, 2);
-noswap1:
- _add(dl, 4);
- goto success;
-topleft:
- _add(dl, 6);
- goto success;
-isinright:
- cx = data.word(kLinestarty);
- _add(cx, 32);
- ax = data.word(kLineendy);
- _add(ax, 32);
- _sub(cx, ax);
- if (!flags.c())
- goto botright;
- _add(dl, 2);
- goto success;
-botright:
- _cmp(dl, 1);
- if (flags.z())
- goto noswap2;
- _xor(dl, 2);
-noswap2:
-success:
- _and(dl, 7);
- data.byte(kTurntoface) = dl;
- data.byte(kTurndirection) = 0;
-}
-
void DreamGenContext::getUnderZoom() {
STACK_CHECK;
di = (8)+5;
diff --git a/engines/dreamweb/dreamgen.h b/engines/dreamweb/dreamgen.h
index 0fb155b6a5..3ac92218a8 100644
--- a/engines/dreamweb/dreamgen.h
+++ b/engines/dreamweb/dreamgen.h
@@ -600,7 +600,6 @@ public:
void cantDrop();
void putUnderZoom();
void findInvPos();
- void workoutFrames();
void rollEndCredits();
void getKeyAndLogo();
void selectOb();
diff --git a/engines/dreamweb/pathfind.cpp b/engines/dreamweb/pathfind.cpp
index 0f717a983f..439ac9b177 100644
--- a/engines/dreamweb/pathfind.cpp
+++ b/engines/dreamweb/pathfind.cpp
@@ -269,4 +269,59 @@ void DreamGenContext::bresenhams() {
}
}
+void DreamBase::workoutFrames() {
+ byte tmp;
+ uint16 diffx, diffy;
+
+ // FIXME: Paranoia asserts, to be removed after sufficient play
+ // testing has happened. Background: The original code used to add
+ // 32 to the four values listed in the asserts below. Which seems
+ // nonsensical, as only the differences of the values matter, so the
+ // +32 cancels out. Unless there is an overflow somewhere... So we
+ // check for that here.
+ assert(data.word(kLinestartx) < 0xFFFF - 32);
+ assert(data.word(kLineendx) < 0xFFFF - 32);
+ assert(data.word(kLinestarty) < 0xFFFF - 32);
+ assert(data.word(kLineendy) < 0xFFFF - 32);
+
+
+ diffx = ABS(data.word(kLinestartx) - data.word(kLineendx));
+ diffy = ABS(data.word(kLinestarty) - data.word(kLineendy));
+
+ if (diffx < diffy) {
+ tmp = 2;
+ if (diffx >= (diffy >> 1))
+ tmp = 1;
+ } else {
+ // tendstohoriz
+ tmp = 0;
+ if (diffy >= (diffx >> 1))
+ tmp = 1;
+ }
+
+ if (data.word(kLinestartx) >= data.word(kLineendx)) {
+ // isinleft
+ if (data.word(kLinestarty) < data.word(kLineendy)) {
+ if (tmp != 1)
+ tmp ^= 2;
+ tmp += 4;
+ } else {
+ // topleft
+ tmp += 6;
+ }
+ } else {
+ // isinright
+ if (data.word(kLinestarty) < data.word(kLineendy)) {
+ tmp += 2;
+ } else {
+ // botright
+ if (tmp != 1)
+ tmp ^= 2;
+ }
+ }
+
+ data.byte(kTurntoface) = tmp & 7;
+ data.byte(kTurndirection) = 0;
+}
+
} // End of namespace DreamGen