aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/graphics/screen.cpp
diff options
context:
space:
mode:
authorColin Snover2016-12-31 20:39:57 -0600
committerColin Snover2017-03-27 19:42:31 -0500
commit31daa956d62b39429cb6638ed3fb549ac488833a (patch)
treefa831adefae05d82209b3f565055f7b761ca8691 /engines/sci/graphics/screen.cpp
parent1298762b7665dc1b7aeedf0271eadfb284309ef1 (diff)
downloadscummvm-rg350-31daa956d62b39429cb6638ed3fb549ac488833a.tar.gz
scummvm-rg350-31daa956d62b39429cb6638ed3fb549ac488833a.tar.bz2
scummvm-rg350-31daa956d62b39429cb6638ed3fb549ac488833a.zip
SCI: Implement bounds-checked reads of game resources
Diffstat (limited to 'engines/sci/graphics/screen.cpp')
-rw-r--r--engines/sci/graphics/screen.cpp37
1 files changed, 19 insertions, 18 deletions
diff --git a/engines/sci/graphics/screen.cpp b/engines/sci/graphics/screen.cpp
index de6df39bb9..e69c432712 100644
--- a/engines/sci/graphics/screen.cpp
+++ b/engines/sci/graphics/screen.cpp
@@ -719,40 +719,41 @@ void GfxScreen::debugShowMap(int mapNo) {
copyToScreen();
}
-void GfxScreen::scale2x(const byte *src, byte *dst, int16 srcWidth, int16 srcHeight, byte bytesPerPixel) {
+void GfxScreen::scale2x(const SciSpan<const byte> &src, SciSpan<byte> &dst, int16 srcWidth, int16 srcHeight, byte bytesPerPixel) {
assert(bytesPerPixel == 1 || bytesPerPixel == 2);
const int newWidth = srcWidth * 2;
const int pitch = newWidth * bytesPerPixel;
- const byte *srcPtr = src;
+ const byte *srcPtr = src.getUnsafeDataAt(0, srcWidth * srcHeight * bytesPerPixel);
+ byte *dstPtr = dst.getUnsafeDataAt(0, srcWidth * srcHeight * bytesPerPixel);
if (bytesPerPixel == 1) {
for (int y = 0; y < srcHeight; y++) {
for (int x = 0; x < srcWidth; x++) {
const byte color = *srcPtr++;
- dst[0] = color;
- dst[1] = color;
- dst[newWidth] = color;
- dst[newWidth + 1] = color;
- dst += 2;
+ dstPtr[0] = color;
+ dstPtr[1] = color;
+ dstPtr[newWidth] = color;
+ dstPtr[newWidth + 1] = color;
+ dstPtr += 2;
}
- dst += newWidth;
+ dstPtr += newWidth;
}
} else if (bytesPerPixel == 2) {
for (int y = 0; y < srcHeight; y++) {
for (int x = 0; x < srcWidth; x++) {
const byte color = *srcPtr++;
const byte color2 = *srcPtr++;
- dst[0] = color;
- dst[1] = color2;
- dst[2] = color;
- dst[3] = color2;
- dst[pitch] = color;
- dst[pitch + 1] = color2;
- dst[pitch + 2] = color;
- dst[pitch + 3] = color2;
- dst += 4;
+ dstPtr[0] = color;
+ dstPtr[1] = color2;
+ dstPtr[2] = color;
+ dstPtr[3] = color2;
+ dstPtr[pitch] = color;
+ dstPtr[pitch + 1] = color2;
+ dstPtr[pitch + 2] = color;
+ dstPtr[pitch + 3] = color2;
+ dstPtr += 4;
}
- dst += pitch;
+ dstPtr += pitch;
}
}
}