[Scummvm-cvs-logs] SF.net SVN: scummvm: [25039] scummvm/trunk/engines/kyra

vinterstum at users.sourceforge.net vinterstum at users.sourceforge.net
Sat Jan 6 19:52:31 CET 2007


Revision: 25039
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25039&view=rev
Author:   vinterstum
Date:     2007-01-06 10:52:30 -0800 (Sat, 06 Jan 2007)

Log Message:
-----------
Merging decodeFrameDeltaPage() again and using Fingolfin's template trickery instead

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/screen.cpp
    scummvm/trunk/engines/kyra/screen.h
    scummvm/trunk/engines/kyra/wsamovie.cpp

Modified: scummvm/trunk/engines/kyra/screen.cpp
===================================================================
--- scummvm/trunk/engines/kyra/screen.cpp	2007-01-06 18:45:43 UTC (rev 25038)
+++ scummvm/trunk/engines/kyra/screen.cpp	2007-01-06 18:52:30 UTC (rev 25039)
@@ -1487,7 +1487,18 @@
 	}
 }
 
-void Screen::decodeFrameDeltaPage(uint8 *dst, const uint8 *src, const int pitch) {
+void Screen::decodeFrameDeltaPage(uint8 *dst, const uint8 *src, int pitch, bool noXor) {
+	debugC(9, kDebugLevelScreen, "Screen::decodeFrameDeltaPage(%p, %p, %d, %d)", (const void *)dst, (const void *)src, pitch, noXor);
+	
+	if (noXor) {
+		wrapped_decodeFrameDeltaPage<true>(dst, src, pitch);
+	} else {
+		wrapped_decodeFrameDeltaPage<false>(dst, src, pitch);
+	}
+}
+
+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);
 	int count = 0;
 	uint8 *dstNext = dst;
@@ -1497,93 +1508,17 @@
 			uint8 len = *src++;
 			code = *src++;
 			while (len--) {
-				*dst++ ^= code;
-				if (++count == pitch) {
-					count = 0;
-					dstNext += SCREEN_W;
-					dst = dstNext;
-				}
-			}
-		} else if (code & 0x80) {
-			code -= 0x80;
-			if (code != 0) {
-				dst += code;
-				
-				count += code;
-				while (count >= pitch) {
-					count -= pitch;
-					dstNext += SCREEN_W;
-					dst = dstNext + count;
-				}
-			} else {
-				uint16 subcode = READ_LE_UINT16(src); src += 2;
-				if (subcode == 0) {
-					break;
-				} else if (subcode & 0x8000) {
-					subcode -= 0x8000;
-					if (subcode & 0x4000) {
-						uint16 len = subcode - 0x4000;
-						code = *src++;
-						while (len--) {
-							*dst++ ^= code;
-							if (++count == pitch) {
-								count = 0;
-								dstNext += SCREEN_W;
-								dst = dstNext;
-							}
-						}
-					} else {
-						while (subcode--) {
-							*dst++ ^= *src++;
-							if (++count == pitch) {
-								count = 0;
-								dstNext += SCREEN_W;
-								dst = dstNext;
-							}
-						}
-					}
+				if (noXor) {
+					*dst++ = code;
 				} else {
-					dst += subcode;
-					
-					count += subcode;
-					while (count >= pitch) {
-						count -= pitch;
-						dstNext += SCREEN_W;
-						dst = dstNext + count;
-					}
-					
+					*dst++ ^= code;
 				}
-			}
-		} else {
-			while (code--) {
-				*dst++ ^= *src++;
 				if (++count == pitch) {
 					count = 0;
 					dstNext += SCREEN_W;
 					dst = dstNext;
 				}
 			}
-		}
-	}
-}
-
-void Screen::decodeFrameDeltaPageNoXor(uint8 *dst, const uint8 *src, const int pitch) {
-	debugC(9, kDebugLevelScreen, "Screen::decodeFrameDeltaPageNoXor(%p, %p, %d)", (const void *)dst, (const void *)src, pitch);
-	int count = 0;
-	uint8 *dstNext = dst;
-	while (1) {
-		uint8 code = *src++;
-		if (code == 0) {
-			uint8 len = *src++;
-			code = *src++;
-			while (len--) {
-				*dst++ = code;
-				if (++count == pitch) {
-					count = 0;
-					dstNext += SCREEN_W;
-					dst = dstNext;
-				}
-			}
 		} else if (code & 0x80) {
 			code -= 0x80;
 			if (code != 0) {
@@ -1605,7 +1540,11 @@
 						uint16 len = subcode - 0x4000;
 						code = *src++;
 						while (len--) {
-							*dst++ = code;
+							if (noXor) {
+								*dst++ = code;
+							} else {
+								*dst++ ^= code;
+							}
 							if (++count == pitch) {
 								count = 0;
 								dstNext += SCREEN_W;
@@ -1614,7 +1553,11 @@
 						}
 					} else {
 						while (subcode--) {
-							*dst++ = *src++;
+							if (noXor) {
+								*dst++ = *src++;
+							} else {
+								*dst++ ^= *src++;
+							}
 							if (++count == pitch) {
 								count = 0;
 								dstNext += SCREEN_W;
@@ -1636,7 +1579,11 @@
 			}
 		} else {
 			while (code--) {
-				*dst++ = *src++;
+				if (noXor) {
+					*dst++ = *src++;
+				} else {
+					*dst++ ^= *src++;
+				}
 				if (++count == pitch) {
 					count = 0;
 					dstNext += SCREEN_W;

Modified: scummvm/trunk/engines/kyra/screen.h
===================================================================
--- scummvm/trunk/engines/kyra/screen.h	2007-01-06 18:45:43 UTC (rev 25038)
+++ scummvm/trunk/engines/kyra/screen.h	2007-01-06 18:52:30 UTC (rev 25039)
@@ -136,8 +136,7 @@
 	static void decodeFrame3(const uint8 *src, uint8 *dst, uint32 size);
 	static void decodeFrame4(const uint8 *src, uint8 *dst, uint32 dstSize);
 	static void decodeFrameDelta(uint8 *dst, const uint8 *src);
-	static void decodeFrameDeltaPage(uint8 *dst, const uint8 *src, const int pitch);
-	static void decodeFrameDeltaPageNoXor(uint8 *dst, const uint8 *src, const int pitch);
+	static void decodeFrameDeltaPage(uint8 *dst, const uint8 *src, const int pitch, bool noXor);
 	
 	uint8 *encodeShape(int x, int y, int w, int h, int flags);
 	void copyRegionToBuffer(int pageNum, int x, int y, int w, int h, uint8 *dest);
@@ -208,6 +207,8 @@
 	void copyScreenFromRect(int x, int y, int w, int h, const uint8 *ptr);
 	void copyScreenToRect(int x, int y, int w, int h, uint8 *ptr);
 
+	template<bool noXor> static void wrapped_decodeFrameDeltaPage(uint8 *dst, const uint8 *src, const int pitch);
+
 	uint8 *_pagePtrs[16];
 	uint8 *_saveLoadPage[8];
 	uint8 *_screenPalette;

Modified: scummvm/trunk/engines/kyra/wsamovie.cpp
===================================================================
--- scummvm/trunk/engines/kyra/wsamovie.cpp	2007-01-06 18:45:43 UTC (rev 25038)
+++ scummvm/trunk/engines/kyra/wsamovie.cpp	2007-01-06 18:52:30 UTC (rev 25039)
@@ -143,7 +143,7 @@
 			if (_flags & WF_OFFSCREEN_DECODE) {
 				Screen::decodeFrameDelta(dst, _deltaBuffer);
 			} else {
-				Screen::decodeFrameDeltaPageNoXor(dst, _deltaBuffer, _width);
+				Screen::decodeFrameDeltaPage(dst, _deltaBuffer, _width, true);
 			}
 		}
 		_currentFrame = 0;
@@ -206,7 +206,7 @@
 	if (_flags & WF_OFFSCREEN_DECODE) {
 		Screen::decodeFrameDelta(dst, _deltaBuffer);
 	} else {
-		Screen::decodeFrameDeltaPage(dst, _deltaBuffer, _width);
+		Screen::decodeFrameDeltaPage(dst, _deltaBuffer, _width, false);
 	}
 }
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list