aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorColin Snover2016-09-24 21:17:25 -0500
committerColin Snover2016-09-29 19:39:16 -0500
commit9d2397e1e9c1be301ddd6e40365e7cf2a1e2f5f5 (patch)
tree26ae1493cd478f1d9b03c04ba3a049dea4fdbe0c /engines
parent3208f063b50f50ba643b94846d096f1d2b298d23 (diff)
downloadscummvm-rg350-9d2397e1e9c1be301ddd6e40365e7cf2a1e2f5f5.tar.gz
scummvm-rg350-9d2397e1e9c1be301ddd6e40365e7cf2a1e2f5f5.tar.bz2
scummvm-rg350-9d2397e1e9c1be301ddd6e40365e7cf2a1e2f5f5.zip
SCI32: Implement kBitmapCreateFromView and kBitmapGetInfo
Used by Torin room 40300 to perform pathfinding by bitmap.
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/kernel_tables.h4
-rw-r--r--engines/sci/engine/kgraphics32.cpp47
-rw-r--r--engines/sci/engine/segment.h9
3 files changed, 51 insertions, 9 deletions
diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h
index 99bcc8fdff..5e14e43622 100644
--- a/engines/sci/engine/kernel_tables.h
+++ b/engines/sci/engine/kernel_tables.h
@@ -395,8 +395,8 @@ static const SciKernelMapSubEntry kBitmap_subops[] = {
{ SIG_SINCE_SCI21MID, 9, MAP_CALL(BitmapCreateFromView), "iii(i)(i)(i)([r0])", NULL },
{ SIG_SINCE_SCI21MID, 10, MAP_CALL(BitmapCopyPixels), "rr", NULL },
{ SIG_SINCE_SCI21MID, 11, MAP_CALL(BitmapClone), "r", NULL },
- { SIG_SINCE_SCI21LATE, 12, MAP_CALL(BitmapGetInfo), "r(i)(i)", NULL },
- { SIG_SINCE_SCI21LATE, 13, MAP_CALL(BitmapScale), "r...ii", NULL },
+ { SIG_SINCE_SCI21MID, 12, MAP_CALL(BitmapGetInfo), "r(i)(i)", NULL },
+ { SIG_SINCE_SCI21LATE,13, MAP_CALL(BitmapScale), "r...ii", NULL },
{ SIG_SCI3, 14, MAP_CALL(BitmapCreateFromUnknown), "......", NULL },
{ SIG_SCI3, 15, MAP_EMPTY(Bitmap), "(.*)", NULL },
{ SIG_SCI3, 16, MAP_EMPTY(Bitmap), "(.*)", NULL },
diff --git a/engines/sci/engine/kgraphics32.cpp b/engines/sci/engine/kgraphics32.cpp
index 3c7a3c2e31..cceb710f33 100644
--- a/engines/sci/engine/kgraphics32.cpp
+++ b/engines/sci/engine/kgraphics32.cpp
@@ -766,9 +766,30 @@ reg_t kBitmapSetDisplace(EngineState *s, int argc, reg_t *argv) {
}
reg_t kBitmapCreateFromView(EngineState *s, int argc, reg_t *argv) {
- // viewId, loopNo, celNo, skipColor, backColor, useRemap, source overlay bitmap
+ CelObjView view(argv[0].toUint16(), argv[1].toSint16(), argv[2].toSint16());
+ const uint8 skipColor = argc > 3 && argv[3].toSint16() != -1 ? argv[3].toSint16() : view._transparentColor;
+ const uint8 backColor = argc > 4 && argv[4].toSint16() != -1 ? argv[4].toSint16() : view._transparentColor;
+ const bool useRemap = argc > 5 ? (bool)argv[5].toSint16() : false;
- return kStub(s, argc + 1, argv - 1);
+ reg_t bitmapId;
+ SciBitmap &bitmap = *s->_segMan->allocateBitmap(&bitmapId, view._width, view._height, skipColor, 0, 0, view._scaledWidth, view._scaledHeight, 0, useRemap, true);
+ Buffer &buffer = bitmap.getBuffer();
+
+ const Common::Rect viewRect(view._width, view._height);
+ buffer.fillRect(viewRect, backColor);
+ view.draw(buffer, viewRect, Common::Point(0, 0), view._mirrorX);
+
+ if (argc > 6 && !argv[6].isNull()) {
+ reg_t clutHandle = argv[6];
+ if (s->_segMan->isObject(clutHandle)) {
+ clutHandle = readSelector(s->_segMan, clutHandle, SELECTOR(data));
+ }
+
+ SciArray &clut = *s->_segMan->lookupArray(clutHandle);
+ bitmap.applyRemap(clut);
+ }
+
+ return bitmapId;
}
reg_t kBitmapCopyPixels(EngineState *s, int argc, reg_t *argv) {
@@ -784,12 +805,24 @@ reg_t kBitmapClone(EngineState *s, int argc, reg_t *argv) {
}
reg_t kBitmapGetInfo(EngineState *s, int argc, reg_t *argv) {
- // bitmap
+ SciBitmap &bitmap = *s->_segMan->lookupBitmap(argv[0]);
- // argc 1 = get width
- // argc 2 = pixel at row 0 col n
- // argc 3 = pixel at row n col n
- return kStub(s, argc + 1, argv - 1);
+ if (argc == 1) {
+ return make_reg(0, bitmap.getWidth());
+ }
+
+ int32 offset;
+ if (argc == 2) {
+ offset = argv[1].toUint16();
+ } else {
+ const int16 x = argv[1].toSint16();
+ const int16 y = argv[2].toSint16();
+ offset = y * bitmap.getWidth() + x;
+ }
+
+ assert(offset >= 0 && offset < bitmap.getWidth() * bitmap.getHeight());
+ const uint8 color = bitmap.getPixels()[offset];
+ return make_reg(0, color);
}
reg_t kBitmapScale(EngineState *s, int argc, reg_t *argv) {
diff --git a/engines/sci/engine/segment.h b/engines/sci/engine/segment.h
index 39376e380c..fd9b3f759e 100644
--- a/engines/sci/engine/segment.h
+++ b/engines/sci/engine/segment.h
@@ -1120,6 +1120,15 @@ public:
}
virtual void saveLoadWithSerializer(Common::Serializer &ser);
+
+ void applyRemap(SciArray &clut) {
+ const int length = getWidth() * getHeight();
+ uint8 *pixel = getPixels();
+ for (int i = 0; i < length; ++i) {
+ uint8 color = clut.int16At(*pixel);
+ *pixel++ = color;
+ }
+ }
};
struct BitmapTable : public SegmentObjTable<SciBitmap> {