aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2011-12-26 02:50:02 +0200
committerFilippos Karapetis2011-12-26 02:50:02 +0200
commit7945a0fbb0ee3ec89d2b4e51d130f47b9717bfd3 (patch)
tree21fc33872bd9b679616e67d599a09c2f1d8d3333 /engines
parent9ba55105fccf0489659d91cee38a899f13628168 (diff)
downloadscummvm-rg350-7945a0fbb0ee3ec89d2b4e51d130f47b9717bfd3.tar.gz
scummvm-rg350-7945a0fbb0ee3ec89d2b4e51d130f47b9717bfd3.tar.bz2
scummvm-rg350-7945a0fbb0ee3ec89d2b4e51d130f47b9717bfd3.zip
DREAMWEB: Cleaned up findFirstPath(), fixed a regression and moved it to DreamBase
Diffstat (limited to 'engines')
-rw-r--r--engines/dreamweb/dreambase.h1
-rw-r--r--engines/dreamweb/object.cpp28
-rw-r--r--engines/dreamweb/pathfind.cpp20
-rw-r--r--engines/dreamweb/structs.h8
-rw-r--r--engines/dreamweb/stubs.h1
5 files changed, 26 insertions, 32 deletions
diff --git a/engines/dreamweb/dreambase.h b/engines/dreamweb/dreambase.h
index 0dc4e52d86..a7b3316dfc 100644
--- a/engines/dreamweb/dreambase.h
+++ b/engines/dreamweb/dreambase.h
@@ -220,6 +220,7 @@ public:
bool checkIfPathIsOn(uint8 index);
void bresenhams();
void workoutFrames();
+ byte findFirstPath(byte x, byte y);
// from people.cpp
void setupInitialReelRoutines();
diff --git a/engines/dreamweb/object.cpp b/engines/dreamweb/object.cpp
index 84829bf440..8e202a0ed0 100644
--- a/engines/dreamweb/object.cpp
+++ b/engines/dreamweb/object.cpp
@@ -341,32 +341,6 @@ void DreamGenContext::openOb() {
_openChangeSize = getOpenedSlotCount() * kItempicsize + kInventx;
}
-uint8 DreamGenContext::findFirstPath(uint16 param) {
- es = data.word(kReels);
- uint16 ptr = 144 * data.byte(kRoomnum);
- // TODO: Replace ax, cx usage with temporary uint8/16 variables...
- cx = param;
-
- for (uint8 pathLoop = 0; pathLoop < 12; pathLoop++, ptr += 8) {
- ax = es.word(ptr+2);
-
- if (ax == 0x0ffff)
- continue; // "nofirst"
-
- if (cl < al || ch < ah)
- continue; // "nofirst"
-
- ax = es.word(ptr+4);
-
- if (cl > al || ch > ah)
- continue; // "nofirst"
-
- return es.byte(ptr+6); // "gotfirst"
- }
-
- return 0;
-}
-
void DreamGenContext::identifyOb() {
if (data.word(kWatchingtime) != 0) {
blank();
@@ -388,7 +362,7 @@ void DreamGenContext::identifyOb() {
data.byte(kPointerspath) = dl;
ax = pop();
push(ax);
- data.byte(kPointerfirstpath) = findFirstPath(ax);
+ data.byte(kPointerfirstpath) = findFirstPath(al, ah);
ax = pop();
byte x = al;
diff --git a/engines/dreamweb/pathfind.cpp b/engines/dreamweb/pathfind.cpp
index 8d9d9a95bb..20bbf7d67e 100644
--- a/engines/dreamweb/pathfind.cpp
+++ b/engines/dreamweb/pathfind.cpp
@@ -309,4 +309,24 @@ void DreamBase::workoutFrames() {
data.byte(kTurndirection) = 0;
}
+byte DreamBase::findFirstPath(byte x, byte y) {
+ PathNode *paths = (PathNode *)getSegment(data.word(kReels)).ptr(kPathdata + 144 * data.byte(kRoomnum), 0);
+
+ for (uint8 index = 0; index < 12; index++) {
+ if (paths[index].x1 == 0xff && paths[index].y1 == 0xff)
+ continue; // "nofirst"
+
+ if (x < paths[index].x1 || y < paths[index].y1)
+ continue; // "nofirst"
+
+ if (x >= paths[index].x2 || y >= paths[index].y2)
+ continue; // "nofirst"
+
+ return paths[index].on; // "gotfirst"
+ }
+
+ return 0;
+}
+
+
} // End of namespace DreamGen
diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h
index d64bcab5d0..b0a168930b 100644
--- a/engines/dreamweb/structs.h
+++ b/engines/dreamweb/structs.h
@@ -221,10 +221,10 @@ struct Change {
struct PathNode {
uint8 x;
uint8 y;
- uint8 b2;
- uint8 b3;
- uint8 b4;
- uint8 b5;
+ uint8 x1;
+ uint8 y1;
+ uint8 x2;
+ uint8 y2;
uint8 on;
uint8 dir;
};
diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h
index 62259a16a5..148436e8a8 100644
--- a/engines/dreamweb/stubs.h
+++ b/engines/dreamweb/stubs.h
@@ -172,7 +172,6 @@
void checkObjectSize();
bool checkObjectSizeCPP();
void openOb();
- uint8 findFirstPath(uint16 param);
void identifyOb();
void selectOb();
void findInvPos();