aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdevtools/tasmrecover/tasm-recover2
-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
5 files changed, 57 insertions, 89 deletions
diff --git a/devtools/tasmrecover/tasm-recover b/devtools/tasmrecover/tasm-recover
index cba8aa9ec7..350a372da6 100755
--- a/devtools/tasmrecover/tasm-recover
+++ b/devtools/tasmrecover/tasm-recover
@@ -724,6 +724,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'wheelsound',
'widedoor',
'width160',
+ 'workoutframes',
'worktoscreen',
'worktoscreenm',
'wornerror',
@@ -912,7 +913,6 @@ generator = cpp(context, "DreamGen", blacklist = [
'findinvpos' : 'findInvPos',
'dumpmenu' : 'dumpMenu',
'liftnoise' : 'liftNoise',
- 'workoutframes' : 'workoutFrames',
'dumpsymbox' : 'dumpSymBox',
'loadgame' : 'loadGame',
'getridoftemp' : 'getRidOfTemp',
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