diff options
Diffstat (limited to 'engines/kyra/screen_v2.cpp')
-rw-r--r-- | engines/kyra/screen_v2.cpp | 90 |
1 files changed, 80 insertions, 10 deletions
diff --git a/engines/kyra/screen_v2.cpp b/engines/kyra/screen_v2.cpp index 7d4b064e2a..cc7d526ffe 100644 --- a/engines/kyra/screen_v2.cpp +++ b/engines/kyra/screen_v2.cpp @@ -117,11 +117,11 @@ void Screen_v2::applyOverlay(int x, int y, int w, int h, int pageNum, const uint } int Screen_v2::findLeastDifferentColor(const uint8 *paletteEntry, const Palette &pal, uint8 firstColor, uint16 numColors, bool skipSpecialColors) { - int m = 0x7fff; + int m = 0x7FFF; int r = 0x101; for (int i = 0; i < numColors; i++) { - if (skipSpecialColors && i >= 0xc0 && i <= 0xc3) + if (skipSpecialColors && i >= 0xC0 && i <= 0xC3) continue; int v = paletteEntry[0] - pal[(i + firstColor) * 3 + 0]; @@ -162,6 +162,34 @@ void Screen_v2::getFadeParams(const Palette &pal, int delay, int &delayInc, int } } +bool Screen_v2::timedPaletteFadeStep(uint8 *pal1, uint8 *pal2, uint32 elapsedTime, uint32 totalTime) { + Palette &p1 = getPalette(1); + + bool res = false; + for (int i = 0; i < p1.getNumColors() * 3; i++) { + uint8 out = 0; + + if (elapsedTime < totalTime) { + int32 d = ((pal2[i] & 0x3F) - (pal1[i] & 0x3F)); + if (d) + res = true; + + int32 val = ((((d << 8) / (int32)totalTime) * (int32)elapsedTime) >> 8); + out = ((pal1[i] & 0x3F) + (int8)val); + } else { + out = p1[i] = (pal2[i] & 0x3F); + res = false; + } + + (*_internFadePalette)[i] = out; + } + + setScreenPalette(*_internFadePalette); + updateScreen(); + + return res; +} + const uint8 *Screen_v2::getPtrToShape(const uint8 *shpFile, int shape) { uint16 shapes = READ_LE_UINT16(shpFile); @@ -283,13 +311,13 @@ void Screen_v2::wsaFrameAnimationStep(int x1, int y1, int x2, int y2, if (w1 == 1) { memset(dt, *s, w2); } else { - t = ((((((w2 - w1 + 1) & 0xffff) << 8) / w1) + 0x100) & 0xffff) << 8; + t = ((((((w2 - w1 + 1) & 0xFFFF) << 8) / w1) + 0x100) & 0xFFFF) << 8; int bp = 0; for (int i = 0; i < w1; i++) { int cnt = (t >> 16); - bp += (t & 0xffff); - if (bp > 0xffff) { - bp -= 0xffff; + bp += (t & 0xFFFF); + if (bp > 0xFFFF) { + bp -= 0xFFFF; cnt++; } memset(dt, *s++, cnt); @@ -300,13 +328,13 @@ void Screen_v2::wsaFrameAnimationStep(int x1, int y1, int x2, int y2, if (w2 == 1) { *dt = *s; } else { - t = (((((w1 - w2) & 0xffff) << 8) / w2) & 0xffff) << 8; + t = (((((w1 - w2) & 0xFFFF) << 8) / w2) & 0xFFFF) << 8; int bp = 0; for (int i = 0; i < w2; i++) { *dt++ = *s++; - bp += (t & 0xffff); - if (bp > 0xffff) { - bp -= 0xffff; + bp += (t & 0xFFFF); + if (bp > 0xFFFF) { + bp -= 0xFFFF; s++; } s += (t >> 16); @@ -322,6 +350,48 @@ void Screen_v2::wsaFrameAnimationStep(int x1, int y1, int x2, int y2, addDirtyRect(x2, y2, w2, h2); } +void Screen_v2::copyPageMemory(int srcPage, int srcPos, int dstPage, int dstPos, int numBytes) { + const uint8 *src = getPagePtr(srcPage) + srcPos; + uint8 *dst = getPagePtr(dstPage) + dstPos; + memcpy(dst, src, numBytes); +} + +void Screen_v2::copyRegionEx(int srcPage, int srcW, int srcH, int dstPage, int dstX, int dstY, int dstW, int dstH, const ScreenDim *dim, bool flag) { + int x0 = dim->sx << 3; + int y0 = dim->sy; + int w0 = dim->w << 3; + int h0 = dim->h; + + int x1 = dstX; + int y1 = dstY; + int w1 = dstW; + int h1 = dstH; + + int x2, y2, w2; + + calcBounds(w0, h0, x1, y1, w1, h1, x2, y2, w2); + + const uint8 *src = getPagePtr(srcPage) + (320 * srcH) + srcW; + uint8 *dst = getPagePtr(dstPage) + 320 * (y0 + y1); + + for (int y = 0; y < h1; y++) { + const uint8 *s = src + x2; + uint8 *d = dst + x0 + x1; + + if (flag) + d += (h1 >> 1); + + for (int x = 0; x < w1; x++) { + if (*s) + *d = *s; + s++; + d++; + } + dst += 320; + src += 320; + } +} + bool Screen_v2::calcBounds(int w0, int h0, int &x1, int &y1, int &w1, int &h1, int &x2, int &y2, int &w2) { x2 = 0; y2 = 0; |