aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorFilippos Karapetis2018-08-25 12:04:26 +0300
committerFilippos Karapetis2018-08-25 12:39:12 +0300
commit66cbaeefe20967348bb5306272f937dba0281021 (patch)
treed7edaa68dbd2159273726dbf774dfa018d7ca884 /engines/sci
parent82e8bc43e60ce5908097d62be1b2fbb59c4679e8 (diff)
downloadscummvm-rg350-66cbaeefe20967348bb5306272f937dba0281021.tar.gz
scummvm-rg350-66cbaeefe20967348bb5306272f937dba0281021.tar.bz2
scummvm-rg350-66cbaeefe20967348bb5306272f937dba0281021.zip
SCI32: Adapt the pathfinding debug code to work woth SCI32 games
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/kpathing.cpp64
-rw-r--r--engines/sci/graphics/frameout.cpp10
-rw-r--r--engines/sci/graphics/frameout.h2
3 files changed, 60 insertions, 16 deletions
diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp
index eb4d5d3748..270f2e60af 100644
--- a/engines/sci/engine/kpathing.cpp
+++ b/engines/sci/engine/kpathing.cpp
@@ -27,6 +27,10 @@
#include "sci/graphics/paint16.h"
#include "sci/graphics/palette.h"
#include "sci/graphics/screen.h"
+#include "sci/graphics/paint32.h"
+#include "sci/graphics/palette32.h"
+#include "sci/graphics/plane32.h"
+#include "sci/graphics/frameout.h"
#include "common/debug-channels.h"
#include "common/list.h"
@@ -292,6 +296,7 @@ static Common::Point readPoint(SegmentRef list_r, int offset) {
point.x = list_r.reg[offset * 2].toUint16();
point.y = list_r.reg[offset * 2 + 1].toUint16();
}
+
return point;
}
@@ -311,12 +316,19 @@ static void draw_line(EngineState *s, Common::Point p1, Common::Point p2, int ty
// Blue: Near-point access
// Red : Barred access
// Yellow: Contained access
- int poly_colors[4] = {
- g_sci->_gfxPalette16->kernelFindColor(0, 255, 0), // green
- g_sci->_gfxPalette16->kernelFindColor(0, 0, 255), // blue
- g_sci->_gfxPalette16->kernelFindColor(255, 0, 0), // red
- g_sci->_gfxPalette16->kernelFindColor(255, 255, 0) // yellow
- };
+ int poly_colors[4];
+
+ if (getSciVersion() <= SCI_VERSION_1_1) {
+ poly_colors[0] = g_sci->_gfxPalette16->kernelFindColor(0, 255, 0); // green
+ poly_colors[1] = g_sci->_gfxPalette16->kernelFindColor(0, 0, 255); // blue
+ poly_colors[2] = g_sci->_gfxPalette16->kernelFindColor(255, 0, 0); // red
+ poly_colors[3] = g_sci->_gfxPalette16->kernelFindColor(255, 255, 0); // yellow
+ } else {
+ poly_colors[0] = g_sci->_gfxPalette32->matchColor(0, 255, 0); // green
+ poly_colors[1] = g_sci->_gfxPalette32->matchColor(0, 0, 255); // blue
+ poly_colors[2] = g_sci->_gfxPalette32->matchColor(255, 0, 0); // red
+ poly_colors[3] = g_sci->_gfxPalette32->matchColor(255, 255, 0); // yellow
+ }
// Clip
// FIXME: Do proper line clipping
@@ -326,17 +338,28 @@ static void draw_line(EngineState *s, Common::Point p1, Common::Point p2, int ty
p2.y = CLIP<int16>(p2.y, 0, height - 1);
assert(type >= 0 && type <= 3);
- g_sci->_gfxPaint16->kernelGraphDrawLine(p1, p2, poly_colors[type], 255, 255);
+
+ if (getSciVersion() <= SCI_VERSION_1_1) {
+ g_sci->_gfxPaint16->kernelGraphDrawLine(p1, p2, poly_colors[type], 255, 255);
+ } else {
+ Plane *topPlane = g_sci->_gfxFrameout->getTopVisiblePlane();
+ g_sci->_gfxPaint32->kernelAddLine(topPlane->_object, p1, p2, 255, poly_colors[type], kLineStyleSolid, 0, 1);
+ }
}
static void draw_point(EngineState *s, Common::Point p, int start, int width, int height) {
// Colors for starting and end point
// Green: End point
// Blue: Starting point
- int point_colors[2] = {
- g_sci->_gfxPalette16->kernelFindColor(0, 255, 0), // green
- g_sci->_gfxPalette16->kernelFindColor(0, 0, 255) // blue
- };
+ int point_colors[2];
+
+ if (getSciVersion() <= SCI_VERSION_1_1) {
+ point_colors[0] = g_sci->_gfxPalette16->kernelFindColor(0, 255, 0); // green
+ point_colors[1] = g_sci->_gfxPalette16->kernelFindColor(0, 0, 255); // blue
+ } else {
+ point_colors[0] = g_sci->_gfxPalette32->matchColor(0, 255, 0); // green
+ point_colors[1] = g_sci->_gfxPalette32->matchColor(0, 0, 255); // blue
+ }
Common::Rect rect = Common::Rect(p.x - 1, p.y - 1, p.x - 1 + 3, p.y - 1 + 3);
@@ -347,8 +370,15 @@ static void draw_point(EngineState *s, Common::Point p, int start, int width, in
rect.right = CLIP<int16>(rect.right, 0, width - 1);
assert(start >= 0 && start <= 1);
- if (g_sci->_gfxPaint16)
+ if (getSciVersion() <= SCI_VERSION_1_1) {
g_sci->_gfxPaint16->kernelGraphFrameBox(rect, point_colors[start]);
+ } else {
+ Plane *topPlane = g_sci->_gfxFrameout->getTopVisiblePlane();
+ g_sci->_gfxPaint32->kernelAddLine(topPlane->_object, Common::Point(rect.left, rect.top), Common::Point(rect.right, rect.top), 255, point_colors[start], kLineStyleSolid, 0, 1);
+ g_sci->_gfxPaint32->kernelAddLine(topPlane->_object, Common::Point(rect.right, rect.top), Common::Point(rect.right, rect.bottom), 255, point_colors[start], kLineStyleSolid, 0, 1);
+ g_sci->_gfxPaint32->kernelAddLine(topPlane->_object, Common::Point(rect.left, rect.bottom), Common::Point(rect.right, rect.bottom), 255, point_colors[start], kLineStyleSolid, 0, 1);
+ g_sci->_gfxPaint32->kernelAddLine(topPlane->_object, Common::Point(rect.left, rect.top), Common::Point(rect.left, rect.bottom), 255, point_colors[start], kLineStyleSolid, 0, 1);
+ }
}
static void draw_polygon(EngineState *s, reg_t polygon, int width, int height) {
@@ -1538,10 +1568,12 @@ reg_t kAvoidPath(EngineState *s, int argc, reg_t *argv) {
}
// Update the whole screen
- g_sci->_gfxScreen->copyToScreen();
- g_system->updateScreen();
- if (!g_sci->_gfxPaint16)
- g_system->delayMillis(2500);
+ if (getSciVersion() <= SCI_VERSION_1_1) {
+ g_sci->_gfxScreen->copyToScreen();
+ g_system->updateScreen();
+ } else {
+ g_sci->_gfxFrameout->kernelFrameOut(true);
+ }
}
PathfindingState *p = convert_polygon_set(s, poly_list, start, end, width, height, opt);
diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp
index 434c5a0fec..505e2063f3 100644
--- a/engines/sci/graphics/frameout.cpp
+++ b/engines/sci/graphics/frameout.cpp
@@ -1354,6 +1354,16 @@ void GfxFrameout::remapMarkRedraw() {
#pragma mark -
#pragma mark Debugging
+Plane *GfxFrameout::getTopVisiblePlane() {
+ for (PlaneList::const_iterator it = _visiblePlanes.begin(); it != _visiblePlanes.end(); ++it) {
+ Plane *p = *it;
+ if (p->_type == kPlaneTypePicture)
+ return p;
+ }
+
+ return nullptr;
+}
+
void GfxFrameout::printPlaneListInternal(Console *con, const PlaneList &planeList) const {
for (PlaneList::const_iterator it = planeList.begin(); it != planeList.end(); ++it) {
Plane *p = *it;
diff --git a/engines/sci/graphics/frameout.h b/engines/sci/graphics/frameout.h
index eddf88f523..f67d53164b 100644
--- a/engines/sci/graphics/frameout.h
+++ b/engines/sci/graphics/frameout.h
@@ -288,6 +288,8 @@ public:
*/
void shakeScreen(const int16 numShakes, const ShakeDirection direction);
+ Plane *getTopVisiblePlane();
+
private:
/**
* The last time the hardware screen was updated.