[Scummvm-git-logs] scummvm master -> 4aae3340fc2b28ecfa8b968846d9d42788bb251f

madmoose thomas at fach-pedersen.net
Sun Jun 14 21:41:04 UTC 2020


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
4aae3340fc KINGDOM: Add support for 16-bit MVE videos


Commit: 4aae3340fc2b28ecfa8b968846d9d42788bb251f
    https://github.com/scummvm/scummvm/commit/4aae3340fc2b28ecfa8b968846d9d42788bb251f
Author: Thomas Fach-Pedersen (thomas at fach-pedersen.net)
Date: 2020-06-14T23:36:05+02:00

Commit Message:
KINGDOM: Add support for 16-bit MVE videos

Changed paths:
    video/mve_decoder.cpp
    video/mve_decoder.h


diff --git a/video/mve_decoder.cpp b/video/mve_decoder.cpp
index 82ac04c500..418ccdbff6 100644
--- a/video/mve_decoder.cpp
+++ b/video/mve_decoder.cpp
@@ -101,7 +101,7 @@ void MveDecoder::applyPalette(PaletteManager *paletteManager) {
 	paletteManager->setPalette(_palette + 3 * _palStart, _palStart, _palCount);
 }
 
-void MveDecoder::copyBlock(Graphics::Surface &dst, Common::MemoryReadStream &s, int block) {
+void MveDecoder::copyBlock_8bit(Graphics::Surface &dst, Common::MemoryReadStream &s, int block) {
 	int x = (block % _widthInBlocks) * 8;
 	int y = (block / _widthInBlocks) * 8;
 
@@ -113,6 +113,20 @@ void MveDecoder::copyBlock(Graphics::Surface &dst, Common::MemoryReadStream &s,
 	}
 }
 
+void MveDecoder::copyBlock_16bit(Graphics::Surface &dst, Common::MemoryReadStream &s, int block) {
+	int x = (block % _widthInBlocks) * 8;
+	int y = (block / _widthInBlocks) * 8;
+
+	byte *p = (byte*)dst.getBasePtr(x, y);
+
+	for (int i = 0; i != 8; ++i) {
+		for (int j = 0; j != 8; ++j) {
+			WRITE_UINT16(p+2*j, s.readUint16LE());
+		}
+		p += dst.pitch;
+	}
+}
+
 void MveDecoder::copyBlock(Graphics::Surface &dst, Graphics::Surface &src, int block, int offset) {
 	int dx = (block % _widthInBlocks) * 8;
 	int dy = (block / _widthInBlocks) * 8;
@@ -124,21 +138,21 @@ void MveDecoder::copyBlock(Graphics::Surface &dst, Graphics::Surface &src, int b
 	byte *sp = (byte*)src.getBasePtr(sx, sy);
 
 	for (int i = 0; i != 8; ++i) {
-		memmove(dp, sp, 8);
+		memmove(dp, sp, !_trueColor ? 8 : 16);
 		dp += dst.pitch;
 		sp += src.pitch;
 	}
 }
 
 void MveDecoder::copyBlock(Graphics::Surface &dst, Graphics::Surface &src, int dx, int dy, int off_x, int off_y) {
-	int sx = dx + + off_x;
-	int sy = dy + + off_y;
+	int sx = dx + off_x;
+	int sy = dy + off_y;
 
 	byte *dp = (byte*)dst.getBasePtr(dx, dy);
 	byte *sp = (byte*)src.getBasePtr(sx, sy);
 
 	for (int i = 0; i != 8; ++i) {
-		memmove(dp, sp, 8);
+		memmove(dp, sp, !_trueColor ? 8 : 16);
 		dp += dst.pitch;
 		sp += src.pitch;
 	}
@@ -156,7 +170,11 @@ void MveDecoder::decodeFormat6() {
 	for (int b = 0; b != _widthInBlocks * _heightInBlocks; ++b) {
 		uint16 op = opStream.readUint16LE();
 		if (op == 0) {
-			copyBlock(_decodeSurface0, frameStream, b);
+			if (!_trueColor) {
+				copyBlock_8bit(_decodeSurface0, frameStream, b);
+			} else {
+				copyBlock_16bit(_decodeSurface0, frameStream, b);
+			}
 		}
 	}
 
@@ -195,7 +213,11 @@ void MveDecoder::decodeFormat10() {
 		if (skipStream.skip()) continue;
 		uint16 op = opStream.readUint16LE();
 		if (op == 0) {
-			copyBlock(_decodeSurface0, frameStream, b);
+			if (!_trueColor) {
+				copyBlock_8bit(_decodeSurface0, frameStream, b);
+			} else {
+				copyBlock_16bit(_decodeSurface0, frameStream, b);
+			}
 		}
 	}
 
@@ -315,7 +337,7 @@ void MveDecoder::readNextPacket() {
 				uint16 width = _s->readUint16LE();
 				uint16 height = _s->readUint16LE();
 				/*uint16 count =*/ _s->readUint16LE();
-				/*uint16 trueColor =*/ _s->readUint16LE();
+				uint16 trueColor = _s->readUint16LE();
 
 				_widthInBlocks = width;
 				_heightInBlocks = height;
@@ -323,13 +345,21 @@ void MveDecoder::readNextPacket() {
 				_width = 8 * width;
 				_height = 8 * height;
 
-				_decodeSurface0.create(_width, _height, Graphics::PixelFormat::createFormatCLUT8());
+				_trueColor = !!trueColor;
+
+				if (!_trueColor) {
+					_pixelFormat = Graphics::PixelFormat::createFormatCLUT8();
+				} else {
+					_pixelFormat = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);
+				}
+
+				_decodeSurface0.create(_width, _height, _pixelFormat);
 				_decodeSurface0.fillRect(Common::Rect(_width, _height), 0);
 
-				_decodeSurface1.create(_width, _height, Graphics::PixelFormat::createFormatCLUT8());
+				_decodeSurface1.create(_width, _height, _pixelFormat);
 				_decodeSurface1.fillRect(Common::Rect(_width, _height), 0);
 
-				_frameSurface.create(_width, _height, Graphics::PixelFormat::createFormatCLUT8());
+				_frameSurface.create(_width, _height, _pixelFormat);
 				_frameSurface.fillRect(Common::Rect(_width, _height), 0);
 
 				addTrack(new MveVideoTrack(this));
diff --git a/video/mve_decoder.h b/video/mve_decoder.h
index 9416e35220..77d377e5b6 100644
--- a/video/mve_decoder.h
+++ b/video/mve_decoder.h
@@ -67,6 +67,8 @@ class MveDecoder : public VideoDecoder {
 
 	Common::Rational _frameRate;
 
+	bool      _trueColor;
+	Graphics::PixelFormat _pixelFormat;
 	bool      _dirtyPalette;
 	uint16    _palStart;
 	uint16    _palCount;
@@ -86,7 +88,8 @@ class MveDecoder : public VideoDecoder {
 	Audio::QueuingAudioStream *_audioStream;
 
 	void readPacketHeader();
-	void copyBlock(Graphics::Surface &dst, Common::MemoryReadStream &s, int block);
+	void copyBlock_8bit(Graphics::Surface &dst, Common::MemoryReadStream &s, int block);
+	void copyBlock_16bit(Graphics::Surface &dst, Common::MemoryReadStream &s, int block);
 	void copyBlock(Graphics::Surface &dst, Graphics::Surface &src, int block, int offset = 0);
 	void copyBlock(Graphics::Surface &dst, Graphics::Surface &src, int dx, int dy, int off_x, int off_y);
 




More information about the Scummvm-git-logs mailing list