aboutsummaryrefslogtreecommitdiff
path: root/engines/toon
diff options
context:
space:
mode:
authorBLooperZ2019-10-14 21:10:18 +0300
committerEugene Sandulenko2019-11-18 02:02:14 +0100
commitd08027ae1f44fdaf0c24594994ba189c59424152 (patch)
tree88c1e969b37d7158ffd59e5c7befbc49e5660e93 /engines/toon
parentff039617bb8bfa832efbf4249c84d9e242f19568 (diff)
downloadscummvm-rg350-d08027ae1f44fdaf0c24594994ba189c59424152.tar.gz
scummvm-rg350-d08027ae1f44fdaf0c24594994ba189c59424152.tar.bz2
scummvm-rg350-d08027ae1f44fdaf0c24594994ba189c59424152.zip
TOON: simplify method to pick subtitles color
Diffstat (limited to 'engines/toon')
-rw-r--r--engines/toon/movie.cpp38
1 files changed, 16 insertions, 22 deletions
diff --git a/engines/toon/movie.cpp b/engines/toon/movie.cpp
index f646eb27f0..d8c3ed4a9f 100644
--- a/engines/toon/movie.cpp
+++ b/engines/toon/movie.cpp
@@ -119,22 +119,21 @@ void Movie::playVideo(bool isFirstIntroVideo) {
} else {
_vm->_system->copyRectToScreen(frame->getPixels(), frame->pitch, 0, 0, frame->w, frame->h);
- int32 currentFrame = _decoder->getCurFrame();
+ int32 currentFrame = _decoder->getCurFrame();
+ // find unused color key to replace with subtitles color
int len = frame->w * frame->h;
- byte pixels[310000] = {0};
- memcpy(pixels, frame->getPixels(), len);
- for (int i = 1; i < 256; i++)
- {
- int j;
- for (j = 0; j < len; j++) {
- if (pixels[j] == i) {
- break;
- }
- }
-
- if (j == len && i != 255) {
- unused = i;
+ const byte* pixels = (const byte *)frame->getPixels();
+ byte counts[256];
+ memset(counts, 0, sizeof(counts));
+ for (int i = 0; i < len; i++) {
+ counts[pixels[i]] = 1;
+ }
+
+ // 0 is already used for the border color and should not be used here, so it can be skipped over.
+ for (int j = 1; j < 256; j++) {
+ if (counts[j] == 0) {
+ unused = j;
break;
}
}
@@ -155,16 +154,11 @@ void Movie::playVideo(bool isFirstIntroVideo) {
}
}
- byte palette[768] = {0};
- memcpy(palette, _decoder->getPalette(), 768);
-
+ byte subtitleColor[3] = {0xff, 0xff, 0x0};
+ _vm->_system->getPaletteManager()->setPalette(_decoder->getPalette(), 0, 256);
if (unused) {
- palette[3 * unused] = 0xff;
- palette[3 * unused + 1] = 0xff;
- palette[3 * unused + 2] = 0x0;
+ _vm->_system->getPaletteManager()->setPalette(subtitleColor, unused, 1);
}
-
- _vm->_system->getPaletteManager()->setPalette(palette, 0, 256);
_vm->_system->updateScreen();
}