aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra/screen_v2.cpp
diff options
context:
space:
mode:
authorJohannes Schickel2008-03-05 17:38:12 +0000
committerJohannes Schickel2008-03-05 17:38:12 +0000
commit130cfded751571069d16caff42baa709146ee501 (patch)
treeb42f1348fce940034fd2ce050ee6f0083d25db84 /engines/kyra/screen_v2.cpp
parent17642259709a4f0b3d81dc83b7294df15e3920aa (diff)
downloadscummvm-rg350-130cfded751571069d16caff42baa709146ee501.tar.gz
scummvm-rg350-130cfded751571069d16caff42baa709146ee501.tar.bz2
scummvm-rg350-130cfded751571069d16caff42baa709146ee501.zip
Implement inventory scrolling for HoF.
svn-id: r31043
Diffstat (limited to 'engines/kyra/screen_v2.cpp')
-rw-r--r--engines/kyra/screen_v2.cpp77
1 files changed, 73 insertions, 4 deletions
diff --git a/engines/kyra/screen_v2.cpp b/engines/kyra/screen_v2.cpp
index 2bec373266..ab46dce6f3 100644
--- a/engines/kyra/screen_v2.cpp
+++ b/engines/kyra/screen_v2.cpp
@@ -84,12 +84,81 @@ void Screen_v2::generateGrayOverlay(const uint8 *srcPal, uint8 *grayOverlay, int
grayOverlay[i] = findLeastDifferentColor(tmpPal + 3 * i, srcPal, lastColor);
}
-void Screen_v2::applyGrayOverlay(int x, int y, int w, int h, int pageNum, const uint8 *grayOverlay) {
+uint8 *Screen_v2::generateOverlay(const uint8 *palette, uint8 *buffer, int startColor, int fac) {
+ if (!palette || !buffer)
+ return buffer;
+
+ fac = MIN(0xFF, fac);
+
+ byte col1, col2, col3;
+ col1 = palette[startColor * 3 + 0];
+ col2 = palette[startColor * 3 + 1];
+ col3 = palette[startColor * 3 + 2];
+ *buffer = 0;
+
+ uint8 *dst = buffer + 1;
+ for (int i = 1; i != 255; ++i) {
+ byte procCol1, procCol2, procCol3;
+ const uint8 *src = palette + i*3;
+ const int factor = (fac >> 1) & 0xFF;
+ byte col;
+
+ col = *src++;
+ col -= ((((col - col1) * factor) << 1) >> 8) & 0xFF;
+ procCol1 = col;
+
+ col = *src++;
+ col -= ((((col - col2) * factor) << 1) >> 8) & 0xFF;
+ procCol2 = col;
+
+ col = *src++;
+ col -= ((((col - col3) * factor) << 1) >> 8) & 0xFF;
+ procCol3 = col;
+
+ uint16 minValue = 0xFFFF;
+ uint8 colorNumber = startColor;
+ const uint8 *pal = palette + 3;
+ for (int count = 0xFF, cur = 1; count > 0; --count, ++cur) {
+ pal += 3;
+ if (cur != i) {
+ uint16 value = 0;
+ pal -= 3;
+ col = *pal++ - procCol1;
+ col *= col;
+ value += col;
+
+ col = *pal++ - procCol2;
+ col *= col;
+ value += col;
+
+ col = *pal++ - procCol3;
+ col *= col;
+ value += col;
+
+ if (value == 0) {
+ colorNumber = i;
+ break;
+ } else if (value < minValue) {
+ minValue = value;
+ colorNumber = cur;
+ }
+ }
+ }
+
+ *dst++ = colorNumber;
+ }
+
+ return buffer;
+}
+
+void Screen_v2::applyOverlay(int x, int y, int w, int h, int pageNum, const uint8 *overlay) {
uint8 * dst = getPagePtr(pageNum) + y * 320 + x;
while (h--) {
- for (int wi = 0; wi < 320; wi++)
- dst[wi] = grayOverlay[dst[wi]];
- dst += 320;
+ for (int wi = 0; wi < w; ++wi) {
+ uint8 index = *dst;
+ *dst++ = overlay[index];
+ }
+ dst += 320 - w;
}
}