aboutsummaryrefslogtreecommitdiff
path: root/engines/sword1/animation.cpp
diff options
context:
space:
mode:
authorTorbjörn Andersson2010-05-23 11:16:10 +0000
committerTorbjörn Andersson2010-05-23 11:16:10 +0000
commit1b294306dd49fb8b97f0e74d94b6c4a89403191c (patch)
treecb07e16548f2a8329c240620bb6a548c389b6f8d /engines/sword1/animation.cpp
parent8ed56e1834487f44c94c6b5c5a4353bb3a889696 (diff)
downloadscummvm-rg350-1b294306dd49fb8b97f0e74d94b6c4a89403191c.tar.gz
scummvm-rg350-1b294306dd49fb8b97f0e74d94b6c4a89403191c.tar.bz2
scummvm-rg350-1b294306dd49fb8b97f0e74d94b6c4a89403191c.zip
Another video player regression: When the palette changes, look up the
lightest/darkest available colours to use as white/black for the subtitles. It is possible that we could get away with fixed values for Broken Sword 2, since it has always had subtitles. But for Broken Sword 1, subtitles is a ScummVM addition, and we can't. svn-id: r49154
Diffstat (limited to 'engines/sword1/animation.cpp')
-rw-r--r--engines/sword1/animation.cpp36
1 files changed, 32 insertions, 4 deletions
diff --git a/engines/sword1/animation.cpp b/engines/sword1/animation.cpp
index a16f000659..441e622184 100644
--- a/engines/sword1/animation.cpp
+++ b/engines/sword1/animation.cpp
@@ -23,7 +23,6 @@
*
*/
-
#include "common/file.h"
#include "sword1/sword1.h"
#include "sword1/animation.h"
@@ -72,6 +71,9 @@ MoviePlayer::MoviePlayer(SwordEngine *vm, Text *textMan, Audio::Mixer *snd, OSys
_bgSoundStream = NULL;
_decoderType = decoderType;
_decoder = decoder;
+
+ _white = 255;
+ _black = 0;
}
MoviePlayer::~MoviePlayer() {
@@ -254,9 +256,35 @@ bool MoviePlayer::playVideo() {
if (frame)
_vm->_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, frame->w, frame->h);
- if (_decoder->hasDirtyPalette())
+ if (_decoder->hasDirtyPalette()) {
_decoder->setSystemPalette();
+ uint32 maxWeight = 0;
+ uint32 minWeight = 0xFFFFFFFF;
+ uint32 weight;
+ byte r, g, b;
+
+ byte *palette = _decoder->getPalette();
+
+ for (int i = 0; i < 256; i++) {
+ r = *palette++;
+ g = *palette++;
+ b = *palette++;
+
+ weight = 3 * r * r + 6 * g * g + 2 * b * b;
+
+ if (weight >= maxWeight) {
+ maxWeight = weight;
+ _white = i;
+ }
+
+ if (weight <= minWeight) {
+ minWeight = weight;
+ _black = i;
+ }
+ }
+ }
+
Graphics::Surface *screen = _vm->_system->lockScreen();
performPostProcessing((byte *)screen->pixels);
_vm->_system->unlockScreen();
@@ -275,11 +303,11 @@ bool MoviePlayer::playVideo() {
}
byte MoviePlayer::findBlackPalIndex() {
- return 0;
+ return _black;
}
byte MoviePlayer::findWhitePalIndex() {
- return 0xff;
+ return _white;
}
DXADecoderWithSound::DXADecoderWithSound(Audio::Mixer *mixer, Audio::SoundHandle *bgSoundHandle)