aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKawa-oneechan2019-06-23 13:27:22 +0200
committerFilippos Karapetis2019-06-23 23:46:38 +0300
commit18716672bb220fdb3fcbc90e5389ba4271fea58f (patch)
treea71ca60e9574c5c073e2dbed89f06371027353b0
parentc0d5981ff9b125e0c56ce68707ade7e07e304206 (diff)
downloadscummvm-rg350-18716672bb220fdb3fcbc90e5389ba4271fea58f.tar.gz
scummvm-rg350-18716672bb220fdb3fcbc90e5389ba4271fea58f.tar.bz2
scummvm-rg350-18716672bb220fdb3fcbc90e5389ba4271fea58f.zip
SCI: Split out duplicated color remapping code
-rw-r--r--engines/sci/graphics/view.cpp47
-rw-r--r--engines/sci/graphics/view.h1
2 files changed, 20 insertions, 28 deletions
diff --git a/engines/sci/graphics/view.cpp b/engines/sci/graphics/view.cpp
index c387a58573..c6d7baadc1 100644
--- a/engines/sci/graphics/view.cpp
+++ b/engines/sci/graphics/view.cpp
@@ -780,6 +780,23 @@ void GfxView::unditherBitmap(SciSpan<byte> &bitmapPtr, int16 width, int16 height
}
}
+byte GfxView::getMappedColor(byte color, uint16 scaleSignal, const Palette *palette, int x2, int y2) {
+ byte outputColor = palette->mapping[color];
+ // SCI16 remapping (QFG4 demo)
+ if (g_sci->_gfxRemap16 && g_sci->_gfxRemap16->isRemapped(outputColor))
+ outputColor = g_sci->_gfxRemap16->remapColor(outputColor, _screen->getVisual(x2, y2));
+ // SCI11+ remapping (Catdate)
+ if ((scaleSignal & 0xFF00) && g_sci->_gfxRemap16 && _resMan->testResource(ResourceId(kResourceTypeVocab, 184))) {
+ if ((scaleSignal >> 8) == 1) // all black
+ outputColor = 0;
+ else if ((scaleSignal >> 8) == 2) // darken
+ outputColor = g_sci->_gfxRemap16->remapColor(253, outputColor);
+ else if ((scaleSignal >> 8) == 3) // shadow
+ outputColor = g_sci->_gfxRemap16->remapColor(253, _screen->getVisual(x2, y2));
+ }
+ return outputColor;
+}
+
void GfxView::draw(const Common::Rect &rect, const Common::Rect &clipRect, const Common::Rect &clipRectTranslated,
int16 loopNo, int16 celNo, byte priority, uint16 EGAmappingNr, bool upscaledHires, uint16 scaleSignal) {
const Palette *palette = _embeddedPal ? &_viewPalette : &_palette->_sysPalette;
@@ -833,20 +850,7 @@ void GfxView::draw(const Common::Rect &rect, const Common::Rect &clipRect, const
const int x2 = clipRectTranslated.left + x;
const int y2 = clipRectTranslated.top + y;
if (priority >= _screen->getPriority(x2, y2)) {
- byte outputColor = palette->mapping[color];
- // SCI16 remapping (QFG4 demo)
- if (g_sci->_gfxRemap16 && g_sci->_gfxRemap16->isRemapped(outputColor))
- outputColor = g_sci->_gfxRemap16->remapColor(outputColor, _screen->getVisual(x2, y2));
- // SCI11+ remapping (Catdate)
- if ((scaleSignal & 0xFF00) && g_sci->_gfxRemap16 && _resMan->testResource(ResourceId(kResourceTypeVocab, 184))) {
- if ((scaleSignal >> 8) == 1) // all black
- outputColor = 0;
- else if ((scaleSignal >> 8) == 2) // darken
- outputColor = g_sci->_gfxRemap16->remapColor(253, outputColor);
- else if ((scaleSignal >> 8) == 3) // shadow
- outputColor = g_sci->_gfxRemap16->remapColor(253, _screen->getVisual(x2, y2));
- }
- _screen->putPixel(x2, y2, drawMask, outputColor, priority, 0);
+ _screen->putPixel(x2, y2, drawMask, getMappedColor(color, scaleSignal, palette, x2, y2), priority, 0);
}
}
}
@@ -933,20 +937,7 @@ void GfxView::drawScaled(const Common::Rect &rect, const Common::Rect &clipRect,
const int x2 = clipRectTranslated.left + x;
const int y2 = clipRectTranslated.top + y;
if (color != clearKey && priority >= _screen->getPriority(x2, y2)) {
- byte outputColor = palette->mapping[color];
- // SCI16 remapping (QFG4 demo)
- if (g_sci->_gfxRemap16 && g_sci->_gfxRemap16->isRemapped(outputColor))
- outputColor = g_sci->_gfxRemap16->remapColor(outputColor, _screen->getVisual(x2, y2));
- // SCI11+ remapping (Catdate)
- if ((scaleSignal & 0xFF00) && g_sci->_gfxRemap16 && _resMan->testResource(ResourceId(kResourceTypeVocab, 184))) {
- if ((scaleSignal >> 8) == 1) // all black
- outputColor = 0;
- else if ((scaleSignal >> 8) == 2) // darken
- outputColor = g_sci->_gfxRemap16->remapColor(253, outputColor);
- else if ((scaleSignal >> 8) == 3) // shadow
- outputColor = g_sci->_gfxRemap16->remapColor(253, _screen->getVisual(x2, y2));
- }
- _screen->putPixel(x2, y2, drawMask, outputColor, priority, 0);
+ _screen->putPixel(x2, y2, drawMask, getMappedColor(color, scaleSignal, palette, x2, y2), priority, 0);
}
}
}
diff --git a/engines/sci/graphics/view.h b/engines/sci/graphics/view.h
index 1876567013..76cc147586 100644
--- a/engines/sci/graphics/view.h
+++ b/engines/sci/graphics/view.h
@@ -85,6 +85,7 @@ private:
void initData(GuiResourceId resourceId);
void unpackCel(int16 loopNo, int16 celNo, SciSpan<byte> &outPtr);
void unditherBitmap(SciSpan<byte> &bitmap, int16 width, int16 height, byte clearKey);
+ byte getMappedColor(byte color, uint16 scaleSignal, const Palette *palette, int x2, int y2);
ResourceManager *_resMan;
GfxCoordAdjuster16 *_coordAdjuster;