aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorFilippos Karapetis2012-06-09 15:36:36 +0300
committerFilippos Karapetis2012-06-09 15:36:36 +0300
commitdc11d223cdb156dd71300a8535cb5ab0940180c1 (patch)
tree939115424acc64a688d1b8749e36cf8a0d76601b /engines/sci
parent66af2cf1d729e5944641ab203f3d36761fdff132 (diff)
downloadscummvm-rg350-dc11d223cdb156dd71300a8535cb5ab0940180c1.tar.gz
scummvm-rg350-dc11d223cdb156dd71300a8535cb5ab0940180c1.tar.bz2
scummvm-rg350-dc11d223cdb156dd71300a8535cb5ab0940180c1.zip
SCI: Initial implementation of AddLine, UpdateLine, DeleteLine
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/kernel.h3
-rw-r--r--engines/sci/engine/kernel_tables.h6
-rw-r--r--engines/sci/engine/kgraphics32.cpp32
-rw-r--r--engines/sci/graphics/frameout.cpp63
-rw-r--r--engines/sci/graphics/frameout.h15
5 files changed, 116 insertions, 3 deletions
diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h
index 664c97f7b5..d9fdbefbc2 100644
--- a/engines/sci/engine/kernel.h
+++ b/engines/sci/engine/kernel.h
@@ -482,6 +482,9 @@ reg_t kScrollWindow(EngineState *s, int argc, reg_t *argv);
reg_t kSetFontRes(EngineState *s, int argc, reg_t *argv);
reg_t kFont(EngineState *s, int argc, reg_t *argv);
reg_t kBitmap(EngineState *s, int argc, reg_t *argv);
+reg_t kAddLine(EngineState *s, int argc, reg_t *argv);
+reg_t kUpdateLine(EngineState *s, int argc, reg_t *argv);
+reg_t kDeleteLine(EngineState *s, int argc, reg_t *argv);
// SCI3 Kernel functions
reg_t kPlayDuck(EngineState *s, int argc, reg_t *argv);
diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h
index 254a479e65..9b765283ec 100644
--- a/engines/sci/engine/kernel_tables.h
+++ b/engines/sci/engine/kernel_tables.h
@@ -568,6 +568,9 @@ static SciKernelMapEntry s_kernelMap[] = {
{ MAP_CALL(SetFontRes), SIG_EVERYWHERE, "ii", NULL, NULL },
{ MAP_CALL(Font), SIG_EVERYWHERE, "i(.*)", NULL, NULL },
{ MAP_CALL(Bitmap), SIG_EVERYWHERE, "(.*)", NULL, NULL },
+ { MAP_CALL(AddLine), SIG_EVERYWHERE, "oiiiiiiiii", NULL, NULL },
+ { MAP_CALL(UpdateLine), SIG_EVERYWHERE, "roiiiiiiiii", NULL, NULL },
+ { MAP_CALL(DeleteLine), SIG_EVERYWHERE, "ro", NULL, NULL },
// SCI2.1 Empty Functions
@@ -613,9 +616,6 @@ static SciKernelMapEntry s_kernelMap[] = {
// SCI2.1 unmapped functions - TODO!
// MovePlaneItems - used by SQ6 to scroll through the inventory via the up/down buttons
- // AddLine - used by Torin's Passage to highlight the chapter buttons
- // DeleteLine - used by Torin's Passage to delete the highlight from the chapter buttons
- // UpdateLine - used by LSL6
// SetPalStyleRange - 2 integer parameters, start and end. All styles from start-end
// (inclusive) are set to 0
// MorphOn - used by SQ6, script 900, the datacorder reprogramming puzzle (from room 270)
diff --git a/engines/sci/engine/kgraphics32.cpp b/engines/sci/engine/kgraphics32.cpp
index 71c4949d65..53cf8ada75 100644
--- a/engines/sci/engine/kgraphics32.cpp
+++ b/engines/sci/engine/kgraphics32.cpp
@@ -605,6 +605,38 @@ reg_t kEditText(EngineState *s, int argc, reg_t *argv) {
return s->r_acc;
}
+reg_t kAddLine(EngineState *s, int argc, reg_t *argv) {
+ reg_t plane = argv[0];
+ Common::Point startPoint(argv[1].toUint16(), argv[2].toUint16());
+ Common::Point endPoint(argv[3].toUint16(), argv[4].toUint16());
+ // argv[5] is unknown (a number, usually 200)
+ byte color = (byte)argv[6].toUint16();
+ byte priority = (byte)argv[7].toUint16();
+ byte control = (byte)argv[8].toUint16();
+ // argv[9] is unknown (usually a small number, 1 or 2). Thickness, perhaps?
+ return g_sci->_gfxFrameout->addPlaneLine(plane, startPoint, endPoint, color, priority, control);
+}
+
+reg_t kUpdateLine(EngineState *s, int argc, reg_t *argv) {
+ reg_t hunkId = argv[0];
+ reg_t plane = argv[1];
+ Common::Point startPoint(argv[2].toUint16(), argv[3].toUint16());
+ Common::Point endPoint(argv[4].toUint16(), argv[5].toUint16());
+ // argv[6] is unknown (a number, usually 200)
+ byte color = (byte)argv[7].toUint16();
+ byte priority = (byte)argv[8].toUint16();
+ byte control = (byte)argv[9].toUint16();
+ // argv[10] is unknown (usually a small number, 1 or 2). Thickness, perhaps?
+ g_sci->_gfxFrameout->updatePlaneLine(plane, hunkId, startPoint, endPoint, color, priority, control);
+ return s->r_acc;
+}
+reg_t kDeleteLine(EngineState *s, int argc, reg_t *argv) {
+ reg_t hunkId = argv[0];
+ reg_t plane = argv[1];
+ g_sci->_gfxFrameout->deletePlaneLine(plane, hunkId);
+ return s->r_acc;
+}
+
#endif
} // End of namespace Sci
diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp
index a5bd8ba48e..db49497b6b 100644
--- a/engines/sci/graphics/frameout.cpp
+++ b/engines/sci/graphics/frameout.cpp
@@ -281,6 +281,56 @@ void GfxFrameout::deletePlanePictures(reg_t object) {
}
}
+// Provides the same functionality as kGraph(DrawLine)
+reg_t GfxFrameout::addPlaneLine(reg_t object, Common::Point startPoint, Common::Point endPoint, byte color, byte priority, byte control) {
+ for (PlaneList::iterator it = _planes.begin(); it != _planes.end(); ++it) {
+ if (it->object == object) {
+ PlaneLineEntry line;
+ line.hunkId = _segMan->allocateHunkEntry("PlaneLine()", 1); // we basically use this for a unique ID
+ line.startPoint = startPoint;
+ line.endPoint = endPoint;
+ line.color = color;
+ line.priority = priority;
+ line.control = control;
+ it->lines.push_back(line);
+ return line.hunkId;
+ }
+ }
+
+ return NULL_REG;
+}
+
+void GfxFrameout::updatePlaneLine(reg_t object, reg_t hunkId, Common::Point startPoint, Common::Point endPoint, byte color, byte priority, byte control) {
+ for (PlaneList::iterator it = _planes.begin(); it != _planes.end(); ++it) {
+ if (it->object == object) {
+ for (PlaneLineList::iterator it2 = it->lines.begin(); it2 != it->lines.end(); ++it2) {
+ if (it2->hunkId == hunkId) {
+ it2->startPoint = startPoint;
+ it2->endPoint = endPoint;
+ it2->color = color;
+ it2->priority = priority;
+ it2->control = control;
+ return;
+ }
+ }
+ }
+ }
+}
+
+void GfxFrameout::deletePlaneLine(reg_t object, reg_t hunkId) {
+ for (PlaneList::iterator it = _planes.begin(); it != _planes.end(); ++it) {
+ if (it->object == object) {
+ for (PlaneLineList::iterator it2 = it->lines.begin(); it2 != it->lines.end(); ++it2) {
+ if (it2->hunkId == hunkId) {
+ _segMan->freeHunkEntry(hunkId);
+ it2 = it->lines.erase(it2);
+ return;
+ }
+ }
+ }
+ }
+}
+
void GfxFrameout::kernelAddScreenItem(reg_t object) {
// Ignore invalid items
if (!_segMan->isObject(object))
@@ -567,6 +617,19 @@ void GfxFrameout::kernelFrameout() {
for (PlaneList::iterator it = _planes.begin(); it != _planes.end(); it++) {
reg_t planeObject = it->object;
+
+ // Draw any plane lines, if they exist
+ // These are drawn on invisible planes as well. (e.g. "invisiblePlane" in LSL6 hires)
+ // FIXME: Lines aren't always drawn (e.g. when the narrator speaks in LSL6 hires).
+ // Perhaps something is painted over them?
+ for (PlaneLineList::iterator it2 = it->lines.begin(); it2 != it->lines.end(); ++it2) {
+ Common::Point startPoint = it2->startPoint;
+ Common::Point endPoint = it2->endPoint;
+ _coordAdjuster->kernelLocalToGlobal(startPoint.x, startPoint.y, it->object);
+ _coordAdjuster->kernelLocalToGlobal(endPoint.x, endPoint.y, it->object);
+ _screen->drawLine(startPoint, endPoint, it2->color, it2->priority, it2->control);
+ }
+
uint16 planeLastPriority = it->lastPriority;
// Update priority here, sq6 sets it w/o UpdatePlane
diff --git a/engines/sci/graphics/frameout.h b/engines/sci/graphics/frameout.h
index 2d2ca6546c..0d80a68f1d 100644
--- a/engines/sci/graphics/frameout.h
+++ b/engines/sci/graphics/frameout.h
@@ -27,6 +27,17 @@ namespace Sci {
class GfxPicture;
+struct PlaneLineEntry {
+ reg_t hunkId;
+ Common::Point startPoint;
+ Common::Point endPoint;
+ byte color;
+ byte priority;
+ byte control;
+};
+
+typedef Common::List<PlaneLineEntry> PlaneLineList;
+
struct PlaneEntry {
reg_t object;
uint16 priority;
@@ -40,6 +51,7 @@ struct PlaneEntry {
Common::Rect upscaledPlaneClipRect;
bool planePictureMirrored;
byte planeBack;
+ PlaneLineList lines;
};
typedef Common::List<PlaneEntry> PlaneList;
@@ -112,6 +124,9 @@ public:
void addPlanePicture(reg_t object, GuiResourceId pictureId, uint16 startX, uint16 startY = 0);
void deletePlanePictures(reg_t object);
+ reg_t addPlaneLine(reg_t object, Common::Point startPoint, Common::Point endPoint, byte color, byte priority, byte control);
+ void updatePlaneLine(reg_t object, reg_t hunkId, Common::Point startPoint, Common::Point endPoint, byte color, byte priority, byte control);
+ void deletePlaneLine(reg_t object, reg_t hunkId);
void clear();
// Scroll text functions