aboutsummaryrefslogtreecommitdiff
path: root/engines/dreamweb/stubs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/dreamweb/stubs.cpp')
-rw-r--r--engines/dreamweb/stubs.cpp27
1 files changed, 24 insertions, 3 deletions
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index 6d2fee1ecd..cd6a9d6b4f 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -886,9 +886,8 @@ void DreamGenContext::autosetwalk() {
al = data.byte(kManspath);
if (data.byte(kFinaldest) == al)
return;
- getroomspaths();
- uint8 *roomsPaths = getroomspathsCPP();
- checkdest();
+ const uint8 *roomsPaths = getroomspathsCPP();
+ checkdest(roomsPaths);
data.word(kLinestartx) = roomsPaths[data.byte(kManspath) * 8 + 0] - 12;
data.word(kLinestarty) = roomsPaths[data.byte(kManspath) * 8 + 1] - 12;
data.word(kLineendx) = roomsPaths[data.byte(kDestination) * 8 + 0] - 12;
@@ -902,5 +901,27 @@ void DreamGenContext::autosetwalk() {
data.byte(kLinepointer) = 0;
}
+void DreamGenContext::checkdest(const uint8 *roomsPaths) {
+ const uint8 *p = roomsPaths + 12 * 8;
+ ah = data.byte(kManspath) << 4;
+ al = data.byte(kDestination);
+ uint8 destination = data.byte(kDestination);
+ for (size_t i = 0; i < 24; ++i) {
+ dh = p[0] & 0xf0;
+ dl = p[0] & 0x0f;
+ if (ax == dx) {
+ data.byte(kDestination) = p[1] & 0x0f;
+ return;
+ }
+ dl = (p[0] & 0xf0) >> 4;
+ dh = (p[0] & 0x0f) << 4;
+ if (ax == dx) {
+ destination = p[1] & 0x0f;
+ }
+ p += 2;
+ }
+ data.byte(kDestination) = destination;
+}
+
} /*namespace dreamgen */