From d61a84e0ab125c6a0208f8d19e91b6b410d0f4f8 Mon Sep 17 00:00:00 2001
From: Johannes Schickel <lordhoto@scummvm.org>
Date: Tue, 9 Jan 2007 11:50:22 +0000
Subject: [PATCH] Fix for bug #1631352 ("KYRA1: Graphics heavily broken and
 ScummVM crash"), I tried memmove here, but it also crashed on Win32 with
 memmove, so I reverted it back to how it was.

svn-id: r25059
---
 engines/kyra/screen.cpp | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp
index 80cb2abc653..b170f613ba7 100644
--- a/engines/kyra/screen.cpp
+++ b/engines/kyra/screen.cpp
@@ -1414,7 +1414,9 @@ void Screen::decodeFrame4(const uint8 *src, uint8 *dst, uint32 dstSize) {
 			int len = MIN(count, (code >> 4) + 3); //upper half of code is the length		
 			int offs = ((code & 0xF) << 8) | *src++; //lower half of code as byte 2 of offset.
 			const uint8 *dstOffs = dst - offs;
-			memcpy(dst, dstOffs, len); dst += len;
+			while (len--) {
+				*dst++ = *dstOffs++;
+			}
 		} else if (code & 0x40) { // 7th bit is set
 			int len = (code & 0x3F) + 3;
 			if (code == 0xFE) {
@@ -1432,12 +1434,16 @@ void Screen::decodeFrame4(const uint8 *src, uint8 *dst, uint32 dstSize) {
 					len = count;
 				}
 				const uint8 *dstOffs = dstOrig + offs;
-				memcpy(dst, dstOffs, len); dst += len;
+				while (len--) {
+					*dst++ = *dstOffs++;
+				}
 			}
 		} else if (code != 0x80) { // not just the 8th bit set.
 			//Copy some bytes from source to dest.
 			int len = MIN(count, code & 0x3F);
-			memcpy(dst, src, len); dst += len; src += len;
+			while (len--) {
+				*dst++ = *src++;
+			}
 		} else {
 			break;
 		}
@@ -1499,7 +1505,7 @@ void Screen::decodeFrameDeltaPage(uint8 *dst, const uint8 *src, int pitch, bool
 
 template<bool noXor>
 void Screen::wrapped_decodeFrameDeltaPage(uint8 *dst, const uint8 *src, int pitch) {
-	debugC(9, kDebugLevelScreen, "Screen::decodeFrameDeltaPage(%p, %p, %d)", (const void *)dst, (const void *)src, pitch);
+	debugC(9, kDebugLevelScreen, "Screen::wrapped_decodeFrameDeltaPage(%p, %p, %d)", (const void *)dst, (const void *)src, pitch);
 	int count = 0;
 	uint8 *dstNext = dst;
 	while (1) {