aboutsummaryrefslogtreecommitdiff
path: root/engines/bladerunner
diff options
context:
space:
mode:
authorPeter Kohaut2019-08-31 23:06:30 +0200
committerPeter Kohaut2019-08-31 23:09:19 +0200
commita7399c5111cc7ebeea284498a1ee5ac7542bb96d (patch)
treef89653b084b58ce909d4487a8251338acaf236d0 /engines/bladerunner
parent6fc73734c12248947ff2214ffd517a32816031c4 (diff)
downloadscummvm-rg350-a7399c5111cc7ebeea284498a1ee5ac7542bb96d.tar.gz
scummvm-rg350-a7399c5111cc7ebeea284498a1ee5ac7542bb96d.tar.bz2
scummvm-rg350-a7399c5111cc7ebeea284498a1ee5ac7542bb96d.zip
BLADERUNNER: Use best pixel format on every platform
Updated all drawing routines to be pixel format agnostic. Might decrease performance.
Diffstat (limited to 'engines/bladerunner')
-rw-r--r--engines/bladerunner/bladerunner.cpp11
-rw-r--r--engines/bladerunner/bladerunner.h19
-rw-r--r--engines/bladerunner/dialogue_menu.cpp8
-rw-r--r--engines/bladerunner/font.cpp19
-rw-r--r--engines/bladerunner/font.h1
-rw-r--r--engines/bladerunner/outtake.cpp2
-rw-r--r--engines/bladerunner/savefile.cpp2
-rw-r--r--engines/bladerunner/shape.cpp6
-rw-r--r--engines/bladerunner/slice_animations.cpp5
-rw-r--r--engines/bladerunner/slice_animations.h2
-rw-r--r--engines/bladerunner/slice_renderer.cpp29
-rw-r--r--engines/bladerunner/slice_renderer.h2
-rw-r--r--engines/bladerunner/ui/esper.cpp106
-rw-r--r--engines/bladerunner/ui/esper.h6
-rw-r--r--engines/bladerunner/ui/kia.cpp1
-rw-r--r--engines/bladerunner/ui/kia_section_diagnostic.cpp2
-rw-r--r--engines/bladerunner/ui/ui_slider.cpp2
-rw-r--r--engines/bladerunner/ui/vk.cpp4
-rw-r--r--engines/bladerunner/vqa_decoder.cpp6
19 files changed, 116 insertions, 117 deletions
diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp
index 2da701f5d3..9262d4129f 100644
--- a/engines/bladerunner/bladerunner.cpp
+++ b/engines/bladerunner/bladerunner.cpp
@@ -324,8 +324,9 @@ Common::Error BladeRunnerEngine::run() {
return Common::Error(Common::kNoGameDataFoundError, missingFileStr);
}
- Graphics::PixelFormat format = screenPixelFormat();
- initGraphics(640, 480, &format);
+ _screenPixelFormat = g_system->getSupportedFormats().front();
+ debug("Using pixel format: %s", _screenPixelFormat.toString().c_str());
+ initGraphics(640, 480, &_screenPixelFormat);
_system->showMouse(true);
@@ -2256,12 +2257,12 @@ Graphics::Surface BladeRunnerEngine::generateThumbnail() const {
for (int x = 0; x < thumbnail.w; ++x) {
uint8 r, g, b;
- uint16 srcPixel = *(const uint16 *)_surfaceFront.getBasePtr(CLIP(x * 8, 0, _surfaceFront.w - 1), CLIP(y * 8, 0, _surfaceFront.h - 1) );
- uint16 *dstPixel = (uint16 *)thumbnail.getBasePtr(CLIP(x, 0, thumbnail.w - 1), CLIP(y, 0, thumbnail.h - 1));
+ uint32 srcPixel = *(const uint32 *)_surfaceFront.getBasePtr(CLIP(x * 8, 0, _surfaceFront.w - 1), CLIP(y * 8, 0, _surfaceFront.h - 1));
+ void *dstPixel = thumbnail.getBasePtr(CLIP(x, 0, thumbnail.w - 1), CLIP(y, 0, thumbnail.h - 1));
// Throw away alpha channel as it is not needed
_surfaceFront.format.colorToRGB(srcPixel, r, g, b);
- *dstPixel = thumbnail.format.RGBToColor(r, g, b);
+ drawPixel(thumbnail, dstPixel, thumbnail.format.RGBToColor(r, g, b));
}
}
diff --git a/engines/bladerunner/bladerunner.h b/engines/bladerunner/bladerunner.h
index 68c8c9b448..8aee6b6416 100644
--- a/engines/bladerunner/bladerunner.h
+++ b/engines/bladerunner/bladerunner.h
@@ -184,6 +184,8 @@ public:
Actor *_actors[kActorCount];
Actor *_playerActor;
+ Graphics::PixelFormat _screenPixelFormat;
+
Graphics::Surface _surfaceFront;
Graphics::Surface _surfaceBack;
@@ -327,8 +329,21 @@ static inline const Graphics::PixelFormat gameDataPixelFormat() {
}
static inline const Graphics::PixelFormat screenPixelFormat() {
- // Should be a format supported by Android port
- return Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0);
+ return ((BladeRunnerEngine*)g_engine)->_screenPixelFormat;
+}
+
+static inline void drawPixel(Graphics::Surface &surface, void* dst, uint32 value) {
+ switch (surface.format.bytesPerPixel) {
+ case 1:
+ *(uint8*)dst = (uint8)value;
+ break;
+ case 2:
+ *(uint16*)dst = (uint16)value;
+ break;
+ case 4:
+ *(uint32*)dst = (uint32)value;
+ break;
+ }
}
void blit(const Graphics::Surface &src, Graphics::Surface &dst);
diff --git a/engines/bladerunner/dialogue_menu.cpp b/engines/bladerunner/dialogue_menu.cpp
index 2a9dcd884c..b7183f31d0 100644
--- a/engines/bladerunner/dialogue_menu.cpp
+++ b/engines/bladerunner/dialogue_menu.cpp
@@ -380,7 +380,7 @@ void DialogueMenu::draw(Graphics::Surface &s) {
for (int i = 0; i != _listSize; ++i) {
_shapes[1].draw(s, x1, y);
_shapes[4].draw(s, x2, y);
- uint16 color = s.format.RGBToColor((_items[i].colorIntensity / 2) * (256 / 32), (_items[i].colorIntensity / 2) * (256 / 32), _items[i].colorIntensity * (256 / 32));
+ uint32 color = s.format.RGBToColor((_items[i].colorIntensity / 2) * (256 / 32), (_items[i].colorIntensity / 2) * (256 / 32), _items[i].colorIntensity * (256 / 32));
_vm->_mainFont->drawString(&s, _items[i].text, x, y, s.w, color);
y += kLineHeight;
}
@@ -552,13 +552,13 @@ void DialogueMenu::darkenRect(Graphics::Surface &s, int x1, int y1, int x2, int
if (x1 < x2 && y1 < y2) {
for (int y = y1; y != y2; ++y) {
for (int x = x1; x != x2; ++x) {
- uint16 *p = (uint16 *)s.getBasePtr(CLIP(x, 0, s.w - 1), CLIP(y, 0, s.h - 1));
+ void *p = s.getBasePtr(CLIP(x, 0, s.w - 1), CLIP(y, 0, s.h - 1));
uint8 r, g, b;
- s.format.colorToRGB(*p, r, g, b);
+ s.format.colorToRGB(*(uint32*)p, r, g, b);
r /= 4;
g /= 4;
b /= 4;
- *p = s.format.RGBToColor(r, g, b);
+ drawPixel(s, p, s.format.RGBToColor(r, g, b));
}
}
}
diff --git a/engines/bladerunner/font.cpp b/engines/bladerunner/font.cpp
index 68e0408585..8ab205eea1 100644
--- a/engines/bladerunner/font.cpp
+++ b/engines/bladerunner/font.cpp
@@ -92,7 +92,6 @@ void Font::reset() {
_screenHeight = 0;
_spacing = 0;
_useFontColor = false;
- _intersperse = 0;
_characters.clear();
}
@@ -118,13 +117,9 @@ void Font::drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 col
return;
}
- uint16 *dstPtr = (uint16 *)dst->getBasePtr(CLIP(x + _characters[characterIndex].x, 0, dst->w - 1), CLIP(y + _characters[characterIndex].y, 0, dst->h - 1));
uint16 *srcPtr = &_data[_characters[characterIndex].dataOffset];
int width = _characters[characterIndex].width;
int height = _characters[characterIndex].height;
- if (_intersperse && y & 1) {
- dstPtr += dst->pitch / 2;
- }
int endY = height + y - 1;
int currentY = y;
@@ -147,23 +142,17 @@ void Font::drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 col
uint8 a, r, g, b;
gameDataPixelFormat().colorToARGB(*srcPtr, a, r, g, b);
if (!a) { // Alpha is inversed
+ uint32 outColor = color;
if (_useFontColor) {
// Ignore the alpha in the output as it is inversed in the input
- *dstPtr = dst->format.RGBToColor(r, g, b);
- } else {
- *dstPtr = (uint16)color;
+ outColor = dst->format.RGBToColor(r, g, b);
}
+ void *dstPtr = dst->getBasePtr(CLIP(currentX + _characters[characterIndex].x, 0, dst->w - 1), CLIP(currentY + _characters[characterIndex].y, 0, dst->h - 1));
+ drawPixel(*dst, dstPtr, outColor);
}
- dstPtr++;
srcPtr++;
currentX++;
}
- dstPtr += dst->pitch / 2 - width;
- if (_intersperse) {
- srcPtr += width;
- dstPtr += dst->pitch / 2;
- currentY++;
- }
currentY++;
}
}
diff --git a/engines/bladerunner/font.h b/engines/bladerunner/font.h
index 38fd305a4d..b874231ac4 100644
--- a/engines/bladerunner/font.h
+++ b/engines/bladerunner/font.h
@@ -55,7 +55,6 @@ class Font : public Graphics::Font {
int _screenHeight;
int _spacing;
bool _useFontColor;
- int _intersperse;
public:
~Font();
diff --git a/engines/bladerunner/outtake.cpp b/engines/bladerunner/outtake.cpp
index cb54816c38..ba02bda21e 100644
--- a/engines/bladerunner/outtake.cpp
+++ b/engines/bladerunner/outtake.cpp
@@ -36,7 +36,7 @@ namespace BladeRunner {
OuttakePlayer::OuttakePlayer(BladeRunnerEngine *vm) {
_vm = vm;
- _surfaceVideo.create(_vm->_surfaceBack.w, _vm->_surfaceBack.h, screenPixelFormat());
+ _surfaceVideo.create(_vm->_surfaceBack.w, _vm->_surfaceBack.h, _vm->_surfaceBack.format);
}
OuttakePlayer::~OuttakePlayer() {
diff --git a/engines/bladerunner/savefile.cpp b/engines/bladerunner/savefile.cpp
index cf55cb038e..1ea1a8807d 100644
--- a/engines/bladerunner/savefile.cpp
+++ b/engines/bladerunner/savefile.cpp
@@ -150,7 +150,7 @@ bool SaveFileManager::readHeader(Common::SeekableReadStream &in, SaveFileHeader
s.read(thumbnailData, kThumbnailSize);
header._thumbnail->init(80, 60, 160, thumbnailData, gameDataPixelFormat());
- header._thumbnail->convertToInPlace(screenPixelFormat());
+
s.seek(pos);
}
diff --git a/engines/bladerunner/shape.cpp b/engines/bladerunner/shape.cpp
index de7a572fa6..60fa869fc1 100644
--- a/engines/bladerunner/shape.cpp
+++ b/engines/bladerunner/shape.cpp
@@ -112,11 +112,11 @@ void Shape::draw(Graphics::Surface &surface, int x, int y) const {
uint8 a, r, g, b;
gameDataPixelFormat().colorToARGB(shpColor, a, r, g, b);
- // Ignore the alpha in the output as it is inversed in the input
- uint16 outColor = (uint16)surface.format.RGBToColor(r, g, b);
if (!a) {
- *(uint16 *)(surface.getBasePtr(CLIP(dst_x + xi, 0, surface.w - 1), CLIP(dst_y + yi, 0, surface.h - 1))) = outColor;
+ // Ignore the alpha in the output as it is inversed in the input
+ void *dstPtr = surface.getBasePtr(CLIP(dst_x + xi, 0, surface.w - 1), CLIP(dst_y + yi, 0, surface.h - 1));
+ drawPixel(surface, dstPtr, surface.format.RGBToColor(r, g, b));
}
}
src_p += 2 * (_width - rect_w);
diff --git a/engines/bladerunner/slice_animations.cpp b/engines/bladerunner/slice_animations.cpp
index 55a3d13e34..d9f44b990f 100644
--- a/engines/bladerunner/slice_animations.cpp
+++ b/engines/bladerunner/slice_animations.cpp
@@ -46,6 +46,8 @@ bool SliceAnimations::open(const Common::String &name) {
_palettes.resize(_paletteCount);
+ Graphics::PixelFormat screenFormat = screenPixelFormat();
+
for (uint32 i = 0; i != _paletteCount; ++i) {
for (uint32 j = 0; j != 256; ++j) {
uint8 color_r = file.readByte();
@@ -57,8 +59,7 @@ bool SliceAnimations::open(const Common::String &name) {
_palettes[i].color[j].b = color_b;
const int bladeToScummVmConstant = 256 / 32; // 5 bits to 8 bits
- uint16 rgb555 = screenPixelFormat().RGBToColor(color_r * bladeToScummVmConstant, color_g * bladeToScummVmConstant, color_b * bladeToScummVmConstant);
- _palettes[i].color555[j] = rgb555;
+ _palettes[i].value[j] = screenFormat.RGBToColor(color_r * bladeToScummVmConstant, color_g * bladeToScummVmConstant, color_b * bladeToScummVmConstant);;
}
}
diff --git a/engines/bladerunner/slice_animations.h b/engines/bladerunner/slice_animations.h
index 79dd6462ee..d9726b5267 100644
--- a/engines/bladerunner/slice_animations.h
+++ b/engines/bladerunner/slice_animations.h
@@ -50,7 +50,7 @@ class SliceAnimations {
};
struct Palette {
- uint16 color555[256];
+ uint32 value[256];
Color256 color[256];
// uint16 &operator[](size_t i) { return color555[i]; }
diff --git a/engines/bladerunner/slice_renderer.cpp b/engines/bladerunner/slice_renderer.cpp
index f797d13b1a..d21fca6193 100644
--- a/engines/bladerunner/slice_renderer.cpp
+++ b/engines/bladerunner/slice_renderer.cpp
@@ -468,8 +468,7 @@ void SliceRenderer::drawInWorld(int animationId, int animationFrame, Vector3 pos
_setEffectColor.b = setEffectColor.b * 31.0f * 65536.0f;
if (frameY >= 0 && frameY < surface.h) {
- // No need to CLIP frameY here in getBasePtr(), since it is within [0, surface.h - 1]
- drawSlice((int)sliceLine, true, (uint16 *)surface.getBasePtr(0, frameY), zBufferLinePtr, frameY);
+ drawSlice((int)sliceLine, true, frameY, surface, zBufferLinePtr);
}
sliceLineIterator.advance();
@@ -531,15 +530,14 @@ void SliceRenderer::drawOnScreen(int animationId, int animationFrame, int screen
while (currentSlice < _frameSliceCount) {
if (currentY >= 0 && currentY < surface.h) {
memset(lineZbuffer, 0xFF, 640 * 2);
- // No need to CLIP currentY here in getBasePtr(), since it is within [0, surface.h - 1]
- drawSlice(currentSlice, false, (uint16 *)surface.getBasePtr(0, currentY), lineZbuffer, currentY);
+ drawSlice(currentSlice, false, currentY, surface, lineZbuffer);
currentSlice += sliceStep;
currentY--;
}
}
}
-void SliceRenderer::drawSlice(int slice, bool advanced, uint16 *frameLinePtr, uint16 *zbufLinePtr, int y) {
+void SliceRenderer::drawSlice(int slice, bool advanced, int y, Graphics::Surface &surface, uint16 *zbufferLine) {
if (slice < 0 || (uint32)slice >= _frameSliceCount) {
return;
}
@@ -554,6 +552,7 @@ void SliceRenderer::drawSlice(int slice, bool advanced, uint16 *frameLinePtr, ui
uint32 polyCount = READ_LE_UINT32(p);
p += 4;
+
while (polyCount--) {
uint32 vertexCount = READ_LE_UINT32(p);
p += 4;
@@ -573,7 +572,7 @@ void SliceRenderer::drawSlice(int slice, bool advanced, uint16 *frameLinePtr, ui
int vertexZ = (_m21lookup[p[0]] + _m22lookup[p[1]] + _m23) / 64;
if (vertexZ >= 0 && vertexZ < 65536) {
- int color555 = palette.color555[p[2]];
+ uint32 outColor = palette.value[p[2]];
if (advanced) {
Color256 aescColor = { 0, 0, 0 };
_screenEffects->getColor(&aescColor, vertexX, y, vertexZ);
@@ -584,12 +583,15 @@ void SliceRenderer::drawSlice(int slice, bool advanced, uint16 *frameLinePtr, ui
color.b = ((int)(_setEffectColor.b + _lightsColor.b * color.b) / 65536) + aescColor.b;
int bladeToScummVmConstant = 256 / 32;
- color555 = _pixelFormat.RGBToColor(CLIP(color.r * bladeToScummVmConstant, 0, 255), CLIP(color.g * bladeToScummVmConstant, 0, 255), CLIP(color.b * bladeToScummVmConstant, 0, 255));
+ outColor = _pixelFormat.RGBToColor(CLIP(color.r * bladeToScummVmConstant, 0, 255), CLIP(color.g * bladeToScummVmConstant, 0, 255), CLIP(color.b * bladeToScummVmConstant, 0, 255));
}
+
for (int x = previousVertexX; x != vertexX; ++x) {
- if (vertexZ < zbufLinePtr[x]) {
- frameLinePtr[x] = color555;
- zbufLinePtr[x] = (uint16)vertexZ;
+ if (vertexZ < zbufferLine[x]) {
+ zbufferLine[x] = (uint16)vertexZ;
+
+ void *dstPtr = surface.getBasePtr(CLIP(x, 0, surface.w - 1), CLIP(y, 0, surface.h - 1));
+ drawPixel(surface, dstPtr, outColor);
}
}
}
@@ -723,17 +725,18 @@ void SliceRenderer::drawShadowPolygon(int transparency, Graphics::Surface &surfa
for (int x = MIN(xMin, xMax); x < MAX(xMin, xMax); ++x) {
uint16 z = zbuffer[x + y * 640];
- uint16 *pixel = (uint16*)surface.getBasePtr(CLIP(x, 0, surface.w - 1), CLIP(y, 0, surface.h - 1));
+ void *pixel = surface.getBasePtr(CLIP(x, 0, surface.w - 1), CLIP(y, 0, surface.h - 1));
if (z >= zMin) {
int index = (x & 3) + ((y & 3) << 2);
if (transparency - ditheringFactor[index] <= 0) {
uint8 r, g, b;
- surface.format.colorToRGB(*pixel, r, g, b);
+ surface.format.colorToRGB(*(uint32*)pixel, r, g, b);
r *= 0.75f;
g *= 0.75f;
b *= 0.75f;
- *pixel = surface.format.RGBToColor(r, g, b);
+
+ drawPixel(surface, pixel, surface.format.RGBToColor(r, g, b));
}
}
}
diff --git a/engines/bladerunner/slice_renderer.h b/engines/bladerunner/slice_renderer.h
index 2e3617162c..85b7d9f916 100644
--- a/engines/bladerunner/slice_renderer.h
+++ b/engines/bladerunner/slice_renderer.h
@@ -114,7 +114,7 @@ private:
Matrix3x2 calculateFacingRotationMatrix();
void loadFrame(int animation, int frame);
- void drawSlice(int slice, bool advanced, uint16 *frameLinePtr, uint16 *zbufLinePtr, int y);
+ void drawSlice(int slice, bool advanced, int y, Graphics::Surface &surface, uint16 *zbufferLine);
void drawShadowInWorld(int transparency, Graphics::Surface &surface, uint16 *zbuffer);
void drawShadowPolygon(int transparency, Graphics::Surface &surface, uint16 *zbuffer);
};
diff --git a/engines/bladerunner/ui/esper.cpp b/engines/bladerunner/ui/esper.cpp
index bb97ae308a..5f49830f44 100644
--- a/engines/bladerunner/ui/esper.cpp
+++ b/engines/bladerunner/ui/esper.cpp
@@ -672,7 +672,7 @@ void ESPER::drawPhotoOpening(Graphics::Surface &surface) {
_timePhotoOpeningNextDiff = 20u;
_timePhotoOpeningNextStart = timeNow;
}
- copyImageScale(&_surfacePhoto, _viewport, &surface, Common::Rect(_screen.left, _screen.top, _photoOpeningWidth, _photoOpeningHeight));
+ copyImageScale(_surfacePhoto, _viewport, surface, Common::Rect(_screen.left, _screen.top, _photoOpeningWidth, _photoOpeningHeight));
surface.hLine(_screen.left, _photoOpeningHeight, _screen.right - 1, surface.format.RGBToColor(0, 248, 0));
surface.vLine(_photoOpeningWidth, _screen.top, _screen.bottom - 1, surface.format.RGBToColor(0, 248, 0));
@@ -830,12 +830,12 @@ void ESPER::drawPhotoSharpening(Graphics::Surface &surface) {
if (_regionSelectedAck && !_regions[_regionSelected].name.empty()) {
_vqaPlayerPhoto->update(true, false);
- copyImageBlur(&_surfaceViewport, Common::Rect(0, 0, 299, 263), &surface, _screen, _blur);
- copyImageBlit(&_surfaceViewport, Common::Rect(0, 0, 0, 0), &surface, Common::Rect(_screen.left, _screen.top, _photoOpeningWidth, _photoOpeningHeight));
+ copyImageBlur(_surfaceViewport, Common::Rect(0, 0, 299, 263), surface, _screen, _blur);
+ copyImageBlit(_surfaceViewport, Common::Rect(0, 0, 0, 0), surface, Common::Rect(_screen.left, _screen.top, _photoOpeningWidth, _photoOpeningHeight));
} else {
drawPhoto(surface);
- copyImageScale(&_surfacePhoto, _viewport, &_surfaceViewport, Common::Rect(0, 0, _screen.width(), _screen.height()));
- copyImageBlit(&_surfaceViewport, Common::Rect(0, 0, 0, 0), &surface, Common::Rect(_screen.left, _screen.top, _photoOpeningWidth, _photoOpeningHeight));
+ copyImageScale(_surfacePhoto, _viewport, _surfaceViewport, Common::Rect(0, 0, _screen.width(), _screen.height()));
+ copyImageBlit(_surfaceViewport, Common::Rect(0, 0, 0, 0), surface, Common::Rect(_screen.left, _screen.top, _photoOpeningWidth, _photoOpeningHeight));
}
drawGrid(surface);
@@ -921,7 +921,7 @@ void ESPER::drawVideoZooming(Graphics::Surface &surface) {
flashViewport();
}
- copyImageBlur(&_surfaceViewport, Common::Rect(0, 0, 299, 263), &surface, _screen, _blur);
+ copyImageBlur(_surfaceViewport, Common::Rect(0, 0, 299, 263), surface, _screen, _blur);
drawGrid(surface);
}
@@ -955,7 +955,7 @@ void ESPER::drawVideoZoomOut(Graphics::Surface &surface) {
if (flash) {
flashViewport();
}
- copyImageBlit(&_surfaceViewport, Common::Rect(0, 0, 0, 0), &surface, _screen);
+ copyImageBlit(_surfaceViewport, Common::Rect(0, 0, 0, 0), surface, _screen);
drawGrid(surface);
// unsigned difference is intentional
if (timeNow - _timeZoomNextStart > _timeZoomNextDiff && _vqaLastFrame <= 0) {
@@ -972,7 +972,7 @@ void ESPER::drawVideoZoomOut(Graphics::Surface &surface) {
}
void ESPER::drawPhoto(Graphics::Surface &surface) {
- copyImageBlur(&_surfacePhoto, _viewport, &surface, _screen, _blur);
+ copyImageBlur(_surfacePhoto, _viewport, surface, _screen, _blur);
}
void ESPER::drawGrid(Graphics::Surface &surface) {
@@ -986,7 +986,7 @@ void ESPER::drawGrid(Graphics::Surface &surface) {
}
void ESPER::drawPhotoWithGrid(Graphics::Surface &surface) {
- copyImageScale(&_surfacePhoto, _viewport, &surface, _screen);
+ copyImageScale(_surfacePhoto, _viewport, surface, _screen);
drawGrid(surface);
}
@@ -1049,7 +1049,7 @@ void ESPER::drawSelection(Graphics::Surface &surface, bool crosshair, int style)
void ESPER::drawVideoFrame(Graphics::Surface &surface) {
_vqaPlayerPhoto->update(true, false);
- copyImageBlit(&_surfaceViewport, Common::Rect(0, 0, 0, 0), &surface, _screen);
+ copyImageBlit(_surfaceViewport, Common::Rect(0, 0, 0, 0), surface, _screen);
}
void ESPER::drawTextCoords(Graphics::Surface &surface) {
@@ -1148,16 +1148,18 @@ void ESPER::drawMouse(Graphics::Surface &surface) {
}
void ESPER::flashViewport() {
- uint16 *ptr = (uint16 *)_surfaceViewport.getPixels();
- for (int i = 0; i < _surfaceViewport.w * _surfaceViewport.h; ++i, ++ptr) {
- uint8 r, g, b;
- _surfaceViewport.format.colorToRGB(*ptr, r, g, b);
- b *= 2;
- *ptr = _surfaceViewport.format.RGBToColor(r, g, b);
+ for (int y = 0; y < _surfaceViewport.h; ++y) {
+ for (int x = 0; x < _surfaceViewport.w; ++x) {
+ uint8 r, g, b;
+ void *ptr = _surfaceViewport.getBasePtr(x, y);
+ _surfaceViewport.format.colorToRGB(*(uint32*)ptr, r, g, b);
+ b *= 2;
+ drawPixel(_surfaceViewport, ptr, _surfaceViewport.format.RGBToColor(r, g, b));
+ }
}
}
-void ESPER::copyImageScale(Graphics::Surface *src, Common::Rect srcRect, Graphics::Surface *dst, Common::Rect dstRect) {
+void ESPER::copyImageScale(Graphics::Surface &src, Common::Rect srcRect, Graphics::Surface &dst, Common::Rect dstRect) {
if (_flash) {
playSound(kSfxBR031_1P, 25);
}
@@ -1175,22 +1177,19 @@ void ESPER::copyImageScale(Graphics::Surface *src, Common::Rect srcRect, Graphic
int srcX = srcRect.left;
int srcXCounter = 0;
for (int dstX = dstRect.left; dstX < dstRect.right; ++dstX) {
- srcX = CLIP(srcX, 0, src->w - 1);
- srcY = CLIP(srcY, 0, src->h - 1);
-
- dstX = CLIP(dstX, 0, dst->w - 1);
- dstY = CLIP(dstY, 0, dst->h - 1);
+ srcX = CLIP(srcX, 0, src.w - 1);
+ srcY = CLIP(srcY, 0, src.h - 1);
- uint16 *srcPtr = (uint16 *)src->getBasePtr(srcX, srcY);
- uint16 *dstPtr = (uint16 *)dst->getBasePtr(dstX, dstY);
+ dstX = CLIP(dstX, 0, dst.w - 1);
+ dstY = CLIP(dstY, 0, dst.h - 1);
uint8 r, g, b;
- src->format.colorToRGB(*srcPtr, r, g, b);
+ src.format.colorToRGB(*(uint32*)src.getBasePtr(srcX, srcY), r, g, b);
if (_flash) {
// add blue-ish tint
b *= 2;
}
- *dstPtr = dst->format.RGBToColor(r, g, b);
+ drawPixel(dst, dst.getBasePtr(dstX, dstY), dst.format.RGBToColor(r, g, b));
srcX += srcDstWidthRatio;
srcXCounter += srcDstWidthRest;
@@ -1221,22 +1220,19 @@ void ESPER::copyImageScale(Graphics::Surface *src, Common::Rect srcRect, Graphic
++srcX;
}
- srcX = CLIP(srcX, 0, src->w - 1);
- srcY = CLIP(srcY, 0, src->h - 1);
-
- dstX = CLIP(dstX, 0, dst->w - 1);
- dstY = CLIP(dstY, 0, dst->h - 1);
+ srcX = CLIP(srcX, 0, src.w - 1);
+ srcY = CLIP(srcY, 0, src.h - 1);
- uint16 *srcPtr = (uint16 *)src->getBasePtr(srcX, srcY);
- uint16 *dstPtr = (uint16 *)dst->getBasePtr(dstX, dstY);
+ dstX = CLIP(dstX, 0, dst.w - 1);
+ dstY = CLIP(dstY, 0, dst.h - 1);
uint8 r, g, b;
- src->format.colorToRGB(*srcPtr, r, g, b);
+ src.format.colorToRGB(*(uint32*)src.getBasePtr(srcX, srcY), r, g, b);
if (_flash) {
// add blue-ish tint
b *= 2;
}
- *dstPtr = dst->format.RGBToColor(r, g, b);
+ drawPixel(dst, dst.getBasePtr(dstX, dstY), dst.format.RGBToColor(r, g, b));
}
srcYCounter += srcRect.height();
@@ -1249,7 +1245,7 @@ void ESPER::copyImageScale(Graphics::Surface *src, Common::Rect srcRect, Graphic
_flash = false;
}
-void ESPER::copyImageBlur(Graphics::Surface *src, Common::Rect srcRect, Graphics::Surface *dst, Common::Rect dstRect, float blur) {
+void ESPER::copyImageBlur(Graphics::Surface &src, Common::Rect srcRect, Graphics::Surface &dst, Common::Rect dstRect, float blur) {
if (_flash) {
playSound(kSfxBR031_1P, 25);
}
@@ -1289,22 +1285,19 @@ void ESPER::copyImageBlur(Graphics::Surface *src, Common::Rect srcRect, Graphics
int skipX = 0;
while (dstX < dstRect.right && skipX < skipXMax) {
- srcX = CLIP(srcX, 0, src->w - 1);
- srcY = CLIP(srcY, 0, src->h - 1);
+ srcX = CLIP(srcX, 0, src.w - 1);
+ srcY = CLIP(srcY, 0, src.h - 1);
- dstX = CLIP(dstX, 0, dst->w - 1);
- dstY = CLIP(dstY, 0, dst->h - 1);
-
- uint16 *srcPtr = (uint16 *)src->getBasePtr(srcX, srcY);
- uint16 *dstPtr = (uint16 *)dst->getBasePtr(dstX, dstY);
+ dstX = CLIP(dstX, 0, dst.w - 1);
+ dstY = CLIP(dstY, 0, dst.h - 1);
uint8 r, g, b;
- src->format.colorToRGB(*srcPtr, r, g, b);
+ src.format.colorToRGB(*(uint32*)src.getBasePtr(srcX, srcY), r, g, b);
if (_flash) {
// add blue-ish tint
b *= 2;
}
- *dstPtr = dst->format.RGBToColor(r, g, b);
+ drawPixel(dst, dst.getBasePtr(dstX, dstY), dst.format.RGBToColor(r, g, b));
++dstX;
++skipX;
@@ -1362,22 +1355,19 @@ void ESPER::copyImageBlur(Graphics::Surface *src, Common::Rect srcRect, Graphics
srcX += 1; // bug in original game? Is using 1 instead of skipX as for Y
}
- srcX = CLIP(srcX, 0, src->w - 1);
- srcY = CLIP(srcY, 0, src->h - 1);
-
- dstX = CLIP(dstX, 0, dst->w - 1);
- dstY = CLIP(dstY, 0, dst->h - 1);
+ srcX = CLIP(srcX, 0, src.w - 1);
+ srcY = CLIP(srcY, 0, src.h - 1);
- uint16 *srcPtr = (uint16 *)src->getBasePtr(srcX, srcY);
- uint16 *dstPtr = (uint16 *)dst->getBasePtr(dstX, dstY);
+ dstX = CLIP(dstX, 0, dst.w - 1);
+ dstY = CLIP(dstY, 0, dst.h - 1);
uint8 r, g, b;
- src->format.colorToRGB(*srcPtr, r, g, b);
+ src.format.colorToRGB(*(uint32*)src.getBasePtr(srcX, srcY), r, g, b);
if (_flash) {
// add blue-ish tint
b *= 2;
}
- *dstPtr = dst->format.RGBToColor(r, g, b);
+ drawPixel(dst, dst.getBasePtr(dstX, dstY), dst.format.RGBToColor(r, g, b));
++dstX;
++skipX;
@@ -1398,12 +1388,12 @@ void ESPER::copyImageBlur(Graphics::Surface *src, Common::Rect srcRect, Graphics
_flash = false;
}
-void ESPER::copyImageBlit(Graphics::Surface *src, Common::Rect srcRect, Graphics::Surface *dst, Common::Rect dstRect) {
+void ESPER::copyImageBlit(Graphics::Surface &src, Common::Rect srcRect, Graphics::Surface &dst, Common::Rect dstRect) {
for (int y = 0; y < dstRect.height(); ++y) {
for (int x = 0; x < dstRect.width(); ++x) {
- uint16 *srcPtr = (uint16 *)src->getBasePtr(CLIP(srcRect.left + x, 0, src->w - 1), CLIP(srcRect.top + y, 0, src->h - 1));
- uint16 *dstPtr = (uint16 *)dst->getBasePtr(CLIP(dstRect.left + x, 0, dst->w - 1), CLIP(dstRect.top + y, 0, dst->h - 1));
- *dstPtr = *srcPtr;
+ uint8 r, g, b;
+ src.format.colorToRGB(*(uint32*)src.getBasePtr(CLIP(srcRect.left + x, 0, src.w - 1), CLIP(srcRect.top + y, 0, src.h - 1)), r, g, b);
+ drawPixel(dst, dst.getBasePtr(CLIP(dstRect.left + x, 0, dst.w - 1), CLIP(dstRect.top + y, 0, dst.h - 1)), dst.format.RGBToColor(r, g, b));
}
}
}
diff --git a/engines/bladerunner/ui/esper.h b/engines/bladerunner/ui/esper.h
index 8360864963..6feb2cae2d 100644
--- a/engines/bladerunner/ui/esper.h
+++ b/engines/bladerunner/ui/esper.h
@@ -247,9 +247,9 @@ private:
void flashViewport();
- void copyImageScale(Graphics::Surface *src, Common::Rect srcRect, Graphics::Surface *dst, Common::Rect dstRect);
- void copyImageBlur(Graphics::Surface *src, Common::Rect srcRect, Graphics::Surface *dst, Common::Rect dstRect, float u);
- void copyImageBlit(Graphics::Surface *src, Common::Rect srcRect, Graphics::Surface *dst, Common::Rect dstRect);
+ void copyImageScale(Graphics::Surface &src, Common::Rect srcRect, Graphics::Surface &dst, Common::Rect dstRect);
+ void copyImageBlur(Graphics::Surface &src, Common::Rect srcRect, Graphics::Surface &dst, Common::Rect dstRect, float u);
+ void copyImageBlit(Graphics::Surface &src, Common::Rect srcRect, Graphics::Surface &dst, Common::Rect dstRect);
void tickSound();
void tickScroll();
diff --git a/engines/bladerunner/ui/kia.cpp b/engines/bladerunner/ui/kia.cpp
index ed5dabcb54..a40a78670e 100644
--- a/engines/bladerunner/ui/kia.cpp
+++ b/engines/bladerunner/ui/kia.cpp
@@ -601,6 +601,7 @@ void KIA::playPhotograph(int photographId) {
void KIA::playImage(const Graphics::Surface &image) {
_playerImage.copyFrom(image);
+ _playerImage.convertToInPlace(screenPixelFormat());
}
void KIA::mouseDownCallback(int buttonId, void *callbackData) {
diff --git a/engines/bladerunner/ui/kia_section_diagnostic.cpp b/engines/bladerunner/ui/kia_section_diagnostic.cpp
index 662aef3621..a5928685f5 100644
--- a/engines/bladerunner/ui/kia_section_diagnostic.cpp
+++ b/engines/bladerunner/ui/kia_section_diagnostic.cpp
@@ -31,7 +31,7 @@
namespace BladeRunner {
-const Color256 KIASectionDiagnostic::kTextColors[] = {
+const Color256 KIASectionDiagnostic::kTextColors[] = {
{ 0, 0, 0 },
{ 16, 8, 8 },
{ 32, 24, 8 },
diff --git a/engines/bladerunner/ui/ui_slider.cpp b/engines/bladerunner/ui/ui_slider.cpp
index 7a8857582f..18538e9c49 100644
--- a/engines/bladerunner/ui/ui_slider.cpp
+++ b/engines/bladerunner/ui/ui_slider.cpp
@@ -115,7 +115,7 @@ void UISlider::draw(Graphics::Surface &surface) {
colorIndex = 3;
}
- uint16 color = surface.format.RGBToColor(kColors[colorIndex].r, kColors[colorIndex].g, kColors[colorIndex].b);
+ uint32 color = surface.format.RGBToColor(kColors[colorIndex].r, kColors[colorIndex].g, kColors[colorIndex].b);
if ((striding + x) & 1 || x == sliderX) {
color = surface.format.RGBToColor(0, 0, 0);
}
diff --git a/engines/bladerunner/ui/vk.cpp b/engines/bladerunner/ui/vk.cpp
index 5fbf763166..06056c33dd 100644
--- a/engines/bladerunner/ui/vk.cpp
+++ b/engines/bladerunner/ui/vk.cpp
@@ -772,8 +772,8 @@ void VK::drawNeedle(Graphics::Surface &surface) {
float colorIntensity = MIN(78.0f, _needleValue + 39.0f) / 78.0f;
- uint16 color1 = surface.format.RGBToColor(56 - 48 * colorIntensity, 144 - 64 * colorIntensity, 184 - 96 * colorIntensity);
- uint16 color2 = surface.format.RGBToColor(56 - 24 * colorIntensity, 144 - 32 * colorIntensity, 184 - 48 * colorIntensity);
+ uint32 color1 = surface.format.RGBToColor(56 - 48 * colorIntensity, 144 - 64 * colorIntensity, 184 - 96 * colorIntensity);
+ uint32 color2 = surface.format.RGBToColor(56 - 24 * colorIntensity, 144 - 32 * colorIntensity, 184 - 48 * colorIntensity);
surface.drawLine(203, 324, x - 2, y, color1);
surface.drawLine(203, 324, x + 2, y, color1);
diff --git a/engines/bladerunner/vqa_decoder.cpp b/engines/bladerunner/vqa_decoder.cpp
index cb7028f764..d3250577c2 100644
--- a/engines/bladerunner/vqa_decoder.cpp
+++ b/engines/bladerunner/vqa_decoder.cpp
@@ -835,11 +835,11 @@ void VQADecoder::VQAVideoTrack::VPTRWriteBlock(Graphics::Surface *surface, unsig
uint8 a, r, g, b;
gameDataPixelFormat().colorToARGB(vqaColor, a, r, g, b);
- // Ignore the alpha in the output as it is inversed in the input
- uint16 outColor = (uint16)surface->format.RGBToColor(r, g, b);
if (!(alpha && a)) {
- *(uint16 *)(surface->getBasePtr(CLIP(dst_x + x, (uint32)0, (uint32)(surface->w - 1)), CLIP(dst_y + y, (uint32)0, (uint32)(surface->h - 1)))) = outColor;
+ void* dstPtr = surface->getBasePtr(CLIP(dst_x + x, (uint32)0, (uint32)(surface->w - 1)), CLIP(dst_y + y, (uint32)0, (uint32)(surface->h - 1)));
+ // Ignore the alpha in the output as it is inversed in the input
+ drawPixel(*surface, dstPtr, surface->format.RGBToColor(r, g, b));
}
}
}