diff options
author | Bertrand Augereau | 2011-09-03 15:09:21 +0200 |
---|---|---|
committer | Bertrand Augereau | 2011-09-03 15:09:21 +0200 |
commit | 20f9028d9d75af0f73933728a35d70b6305a1687 (patch) | |
tree | cb2015bb52eff794e3ef5a415c0615c93412121a /engines | |
parent | 4782c7e34e83cdef57c613c08bb313ea4c6fbd24 (diff) | |
download | scummvm-rg350-20f9028d9d75af0f73933728a35d70b6305a1687.tar.gz scummvm-rg350-20f9028d9d75af0f73933728a35d70b6305a1687.tar.bz2 scummvm-rg350-20f9028d9d75af0f73933728a35d70b6305a1687.zip |
DREAMWEB: Refining of the pathfinding structures
Diffstat (limited to 'engines')
-rw-r--r-- | engines/dreamweb/pathfind.cpp | 41 | ||||
-rw-r--r-- | engines/dreamweb/sprite.cpp | 4 | ||||
-rw-r--r-- | engines/dreamweb/structs.h | 14 | ||||
-rw-r--r-- | engines/dreamweb/stubs.h | 4 |
4 files changed, 36 insertions, 27 deletions
diff --git a/engines/dreamweb/pathfind.cpp b/engines/dreamweb/pathfind.cpp index 873fe794cb..ef07199211 100644 --- a/engines/dreamweb/pathfind.cpp +++ b/engines/dreamweb/pathfind.cpp @@ -33,7 +33,7 @@ void DreamGenContext::turnpathon() { void DreamGenContext::turnpathon(uint8 param) { findormake(param, 0xff, data.byte(kRoomnum) + 100); - Path *roomsPaths = getroomspathsCPP(); + PathNode *roomsPaths = getroomspathsCPP()->nodes; if (param == 0xff) return; roomsPaths[param].b6 = 0xff; @@ -45,7 +45,7 @@ void DreamGenContext::turnpathoff() { void DreamGenContext::turnpathoff(uint8 param) { findormake(param, 0x00, data.byte(kRoomnum) + 100); - Path *roomsPaths = getroomspathsCPP(); + PathNode *roomsPaths = getroomspathsCPP()->nodes; if (param == 0xff) return; roomsPaths[param].b6 = 0x00; @@ -53,7 +53,7 @@ void DreamGenContext::turnpathoff(uint8 param) { void DreamGenContext::turnanypathon(uint8 param, uint8 room) { findormake(param, 0xff, room + 100); - Path *paths = (Path *)segRef(data.word(kReels)).ptr(kPathdata + 144 * room, 0); + PathNode *paths = (PathNode *)segRef(data.word(kReels)).ptr(kPathdata + 144 * room, 0); paths[param].b6 = 0xff; } @@ -64,7 +64,7 @@ void DreamGenContext::turnanypathon() { void DreamGenContext::turnanypathoff(uint8 param, uint8 room) { findormake(param, 0x00, room + 100); - Path *paths = (Path *)segRef(data.word(kReels)).ptr(kPathdata + 144 * room, 0); + PathNode *paths = (PathNode *)segRef(data.word(kReels)).ptr(kPathdata + 144 * room, 0); paths[param].b6 = 0x00; } @@ -77,21 +77,21 @@ void DreamGenContext::getroomspaths() { bx = data.byte(kRoomnum) * 144; } -Path *DreamGenContext::getroomspathsCPP() { +RoomPaths *DreamGenContext::getroomspathsCPP() { void *result = segRef(data.word(kReels)).ptr(data.byte(kRoomnum) * 144, 144); - return (Path *)result; + return (RoomPaths *)result; } void DreamGenContext::autosetwalk() { al = data.byte(kManspath); if (data.byte(kFinaldest) == al) return; - const Path *roomsPaths = getroomspathsCPP(); + const RoomPaths *roomsPaths = getroomspathsCPP(); checkdest(roomsPaths); - data.word(kLinestartx) = roomsPaths[data.byte(kManspath)].x - 12; - data.word(kLinestarty) = roomsPaths[data.byte(kManspath)].y - 12; - data.word(kLineendx) = roomsPaths[data.byte(kDestination)].x - 12; - data.word(kLineendy) = roomsPaths[data.byte(kDestination)].y - 12; + data.word(kLinestartx) = roomsPaths->nodes[data.byte(kManspath)].x - 12; + data.word(kLinestarty) = roomsPaths->nodes[data.byte(kManspath)].y - 12; + data.word(kLineendx) = roomsPaths->nodes[data.byte(kDestination)].x - 12; + data.word(kLineendy) = roomsPaths->nodes[data.byte(kDestination)].y - 12; bresenhams(); if (data.byte(kLinedirection) != 0) { data.byte(kLinepointer) = data.byte(kLinelength) - 1; @@ -101,30 +101,29 @@ void DreamGenContext::autosetwalk() { data.byte(kLinepointer) = 0; } -void DreamGenContext::checkdest(const Path *roomsPaths) { - const uint8 *p = (const uint8 *)roomsPaths + 12 * 8; +void DreamGenContext::checkdest(const RoomPaths *roomsPaths) { + const PathSegment *segments = roomsPaths->segments; 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; + dh = segments[i].b0 & 0xf0; + dl = segments[i].b0 & 0x0f; if (ax == dx) { - data.byte(kDestination) = p[1] & 0x0f; + data.byte(kDestination) = segments[i].b1 & 0x0f; return; } - dl = (p[0] & 0xf0) >> 4; - dh = (p[0] & 0x0f) << 4; + dl = (segments[i].b0 & 0xf0) >> 4; + dh = (segments[i].b0 & 0x0f) << 4; if (ax == dx) { - destination = p[1] & 0x0f; + destination = segments[i].b1 & 0x0f; } - p += 2; } data.byte(kDestination) = destination; } void DreamGenContext::findxyfrompath() { - const Path *roomsPaths = getroomspathsCPP(); + const PathNode *roomsPaths = getroomspathsCPP()->nodes; data.byte(kRyanx) = roomsPaths[data.byte(kManspath)].x - 12; data.byte(kRyany) = roomsPaths[data.byte(kManspath)].y - 12; } diff --git a/engines/dreamweb/sprite.cpp b/engines/dreamweb/sprite.cpp index 8de829ae05..e938f868a5 100644 --- a/engines/dreamweb/sprite.cpp +++ b/engines/dreamweb/sprite.cpp @@ -501,8 +501,8 @@ void DreamGenContext::liftsprite(Sprite *sprite, SetObject *objData) { } void DreamGenContext::facerightway() { - Path *paths = getroomspathsCPP(); - uint8 dir = paths[data.byte(kManspath)].b7; + PathNode *paths = getroomspathsCPP()->nodes; + uint8 dir = paths[data.byte(kManspath)].dir; data.byte(kTurntoface) = dir; data.byte(kLeavedirection) = dir; } diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index c0d5636538..7c9d9a5814 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -228,7 +228,7 @@ struct Change { uint8 type; }; -struct Path { +struct PathNode { uint8 x; uint8 y; uint8 b2; @@ -236,6 +236,16 @@ struct Path { uint8 b4; uint8 b5; uint8 b6; - uint8 b7; + uint8 dir; +}; + +struct PathSegment { + uint8 b0; + uint8 b1; +}; + +struct RoomPaths { + PathNode nodes[12]; + PathSegment segments[24]; }; diff --git a/engines/dreamweb/stubs.h b/engines/dreamweb/stubs.h index 2602f11a9c..15ff2ee62c 100644 --- a/engines/dreamweb/stubs.h +++ b/engines/dreamweb/stubs.h @@ -84,7 +84,7 @@ void facerightway(); void walking(Sprite *sprite); void autosetwalk(); - void checkdest(const Path *roomsPaths); + void checkdest(const RoomPaths *roomsPaths); void aboutturn(Sprite *sprite); void backobject(Sprite *sprite); void constant(Sprite *sprite, SetObject *objData); @@ -112,7 +112,7 @@ void turnanypathon(); void turnanypathoff(); void getroomspaths(); - Path *getroomspathsCPP(); + RoomPaths *getroomspathsCPP(); void makebackob(SetObject *objData); void modifychar(); void lockmon(); |