aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2008-07-27 12:12:40 +0000
committerJohannes Schickel2008-07-27 12:12:40 +0000
commit7e7468b322d928a28243a3e03bc64e87dda4fadc (patch)
tree78a634b22c5f51001966e9de03834a40eae08e46
parentb95c05c384fd99e1deb75245aa295a5de64b9091 (diff)
downloadscummvm-rg350-7e7468b322d928a28243a3e03bc64e87dda4fadc.tar.gz
scummvm-rg350-7e7468b322d928a28243a3e03bc64e87dda4fadc.tar.bz2
scummvm-rg350-7e7468b322d928a28243a3e03bc64e87dda4fadc.zip
- Fixed fadePalette for HoF and Kyra3
- Fixed bug in wsaFrameAnimationStep svn-id: r33334
-rw-r--r--engines/kyra/screen.cpp109
-rw-r--r--engines/kyra/screen.h6
-rw-r--r--engines/kyra/screen_v2.cpp26
-rw-r--r--engines/kyra/screen_v2.h2
4 files changed, 95 insertions, 48 deletions
diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp
index 6e7a88b1a3..74f7bc6de9 100644
--- a/engines/kyra/screen.cpp
+++ b/engines/kyra/screen.cpp
@@ -380,61 +380,23 @@ void Screen::fadePalette(const uint8 *palData, int delay, const UpdateFunctor *u
debugC(9, kDebugLevelScreen, "Screen::fadePalette(%p, %d, %p)", (const void *)palData, delay, (const void*)upFunc);
updateScreen();
- uint8 fadePal[768];
- memcpy(fadePal, _screenPalette, 768);
- uint8 diff, maxDiff = 0;
- for (int i = 0; i < 768; ++i) {
- diff = ABS(palData[i] - fadePal[i]);
- if (diff > maxDiff) {
- maxDiff = diff;
- }
- }
-
- int16 delayInc = delay << 8;
- if (maxDiff != 0)
- delayInc /= maxDiff;
-
- delay = delayInc;
- for (diff = 1; diff <= maxDiff; ++diff) {
- if (delayInc >= 512)
- break;
- delayInc += delay;
- }
+ int diff = 0, delayInc = 0;
+ getFadeParams(palData, delay, delayInc, diff);
int delayAcc = 0;
while (!_vm->quit()) {
delayAcc += delayInc;
- bool needRefresh = false;
- for (int i = 0; i < 768; ++i) {
- int c1 = palData[i];
- int c2 = fadePal[i];
- if (c1 != c2) {
- needRefresh = true;
- if (c1 > c2) {
- c2 += diff;
- if (c1 < c2)
- c2 = c1;
- }
-
- if (c1 < c2) {
- c2 -= diff;
- if (c1 > c2)
- c2 = c1;
- }
-
- fadePal[i] = (uint8)c2;
- }
- }
- if (!needRefresh)
- break;
+ int refreshed = fadePalStep(palData, diff);
- setScreenPalette(fadePal);
if (upFunc && upFunc->isValid())
(*upFunc)();
else
_system->updateScreen();
- //_system->delayMillis((delayAcc >> 8) * 1000 / 60);
+
+ if (!refreshed)
+ break;
+
_vm->delay((delayAcc >> 8) * 1000 / 60);
delayAcc &= 0xFF;
}
@@ -448,6 +410,61 @@ void Screen::fadePalette(const uint8 *palData, int delay, const UpdateFunctor *u
}
}
+void Screen::getFadeParams(const uint8 *palette, int delay, int &delayInc, int &diff) {
+ debugC(9, kDebugLevelScreen, "Screen::getFadeParams(%p, %d, %p, %p)", (const void *)palette, delay, (const void *)&delayInc, (const void *)&diff);
+ uint8 maxDiff = 0;
+ for (int i = 0; i < 768; ++i) {
+ diff = ABS(palette[i] - _screenPalette[i]);
+ maxDiff = MAX<uint8>(maxDiff, diff);
+ }
+
+ delayInc = delay << 8;
+ if (maxDiff != 0)
+ delayInc /= maxDiff;
+ delayInc &= 0x7FFF;
+
+ delay = delayInc;
+ for (diff = 1; diff <= maxDiff; ++diff) {
+ if (delayInc >= 512)
+ break;
+ delayInc += delay;
+ }
+}
+
+int Screen::fadePalStep(const uint8 *palette, int diff) {
+ debugC(9, kDebugLevelScreen, "Screen::fadePalStep(%p, %d)", (const void *)palette, diff);
+
+ uint8 fadePal[768];
+ memcpy(fadePal, _screenPalette, 768);
+
+ bool needRefresh = false;
+ for (int i = 0; i < 768; ++i) {
+ int c1 = palette[i];
+ int c2 = fadePal[i];
+ if (c1 != c2) {
+ needRefresh = true;
+ if (c1 > c2) {
+ c2 += diff;
+ if (c1 < c2)
+ c2 = c1;
+ }
+
+ if (c1 < c2) {
+ c2 -= diff;
+ if (c1 > c2)
+ c2 = c1;
+ }
+
+ fadePal[i] = (uint8)c2;
+ }
+ }
+
+ if (needRefresh)
+ setScreenPalette(fadePal);
+
+ return needRefresh ? 1 : 0;
+}
+
void Screen::setPaletteIndex(uint8 index, uint8 red, uint8 green, uint8 blue) {
debugC(9, kDebugLevelScreen, "Screen::setPaletteIndex(%u, %u, %u, %u)", index, red, green, blue);
_currentPalette[index * 3 + 0] = red;
@@ -2442,7 +2459,7 @@ void Screen::setShapePages(int page1, int page2, int minY, int maxY) {
_maskMaxY = maxY;
}
-void Screen::setMouseCursor(int x, int y, byte *shape) {
+void Screen::setMouseCursor(int x, int y, const byte *shape) {
debugC(9, kDebugLevelScreen, "Screen::setMouseCursor(%d, %d, %p)", x, y, (const void *)shape);
if (!shape)
return;
diff --git a/engines/kyra/screen.h b/engines/kyra/screen.h
index f8c85a2bac..99ba2d7c5f 100644
--- a/engines/kyra/screen.h
+++ b/engines/kyra/screen.h
@@ -89,10 +89,12 @@ public:
enum FontId {
FID_6_FNT = 0,
FID_8_FNT,
+ FID_9_FNT,
FID_CRED6_FNT,
FID_CRED8_FNT,
FID_BOOKFONT_FNT,
FID_GOLDFONT_FNT,
+ FID_INTRO_FNT,
FID_NUM
};
@@ -145,6 +147,8 @@ public:
void fadeToBlack(int delay=0x54, const UpdateFunctor *upFunc = 0);
void fadePalette(const uint8 *palData, int delay, const UpdateFunctor *upFunc = 0);
+ virtual void getFadeParams(const uint8 *palette, int delay, int &delayInc, int &diff);
+ int fadePalStep(const uint8 *palette, int diff);
void setPaletteIndex(uint8 index, uint8 red, uint8 green, uint8 blue);
void setScreenPalette(const uint8 *palData);
@@ -189,7 +193,7 @@ public:
void hideMouse();
void showMouse();
bool isMouseVisible() const;
- void setMouseCursor(int x, int y, byte *shape);
+ void setMouseCursor(int x, int y, const byte *shape);
// rect handling
virtual int getRectSize(int w, int h) = 0;
diff --git a/engines/kyra/screen_v2.cpp b/engines/kyra/screen_v2.cpp
index e26ef87bad..e5d851aeab 100644
--- a/engines/kyra/screen_v2.cpp
+++ b/engines/kyra/screen_v2.cpp
@@ -111,6 +111,30 @@ int Screen_v2::findLeastDifferentColor(const uint8 *paletteEntry, const uint8 *p
return r;
}
+void Screen_v2::getFadeParams(const uint8 *palette, int delay, int &delayInc, int &diff) {
+ debugC(9, kDebugLevelScreen, "Screen_v2::getFadeParams(%p, %d, %p, %p)", (const void *)palette, delay, (const void *)&delayInc, (const void *)&diff);
+
+ int maxDiff = 0;
+ diff = 0;
+ for (int i = 0; i < 768; ++i) {
+ diff = ABS(palette[i] - _screenPalette[i]);
+ maxDiff = MAX(maxDiff, diff);
+ }
+
+ delayInc = delay << 8;
+ if (maxDiff != 0) {
+ delayInc /= maxDiff;
+ delayInc = MIN(delayInc, 0x7FFF);
+ }
+
+ delay = delayInc;
+ for (diff = 1; diff <= maxDiff; ++diff) {
+ if (delayInc >= 256)
+ break;
+ delayInc += delay;
+ }
+}
+
void Screen_v2::copyWsaRect(int x, int y, int w, int h, int dimState, int plotFunc, const uint8 *src,
int unk1, const uint8 *unkPtr1, const uint8 *unkPtr2) {
uint8 *dstPtr = getPagePtr(_curPage);
@@ -369,7 +393,7 @@ void Screen_v2::wsaFrameAnimationStep(int x1, int y1, int x2, int y2,
int t = (nb * h1) / h2;
if (t != u) {
u = t;
- const uint8 *s = src + (x1 + t) * 320;
+ const uint8 *s = src + x1 + t * 320;
uint8 *dt = (uint8 *)_wsaFrameAnimBuffer;
t = w2 - w1;
diff --git a/engines/kyra/screen_v2.h b/engines/kyra/screen_v2.h
index f624228445..3283526ee3 100644
--- a/engines/kyra/screen_v2.h
+++ b/engines/kyra/screen_v2.h
@@ -44,6 +44,8 @@ public:
uint8 *generateOverlay(const uint8 *palette, uint8 *buffer, int color, uint16 factor);
void applyOverlay(int x, int y, int w, int h, int pageNum, const uint8 *overlay);
int findLeastDifferentColor(const uint8 *paletteEntry, const uint8 *palette, uint16 numColors);
+
+ virtual void getFadeParams(const uint8 *palette, int delay, int &delayInc, int &diff);
// shape handling
uint8 *getPtrToShape(uint8 *shpFile, int shape);