[Scummvm-cvs-logs] CVS: scummvm/scumm wiz_he.h,2.32,2.33 wiz_he.cpp,2.98,2.99

kirben kirben at users.sourceforge.net
Thu Oct 20 18:35:41 CEST 2005


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22881/scumm

Modified Files:
	wiz_he.h wiz_he.cpp 
Log Message:

Add XMAP support for wizImages.


Index: wiz_he.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/wiz_he.h,v
retrieving revision 2.32
retrieving revision 2.33
diff -u -d -r2.32 -r2.33
--- wiz_he.h	18 Oct 2005 19:16:17 -0000	2.32
+++ wiz_he.h	21 Oct 2005 01:34:41 -0000	2.33
@@ -186,10 +186,10 @@
 	void processWizImage(const WizParameters *params);
 
 	static void copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch);
-	static void copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, const uint8 *palPtr = NULL);
+	static void copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, const uint8 *palPtr = NULL, const uint8 *xmapPtr = NULL);
 	static void copyRawWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor);
 	static void copyRaw16BitWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor);
-	static void decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect, const uint8 *palPtr = NULL);
+	static void decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect, const uint8 *palPtr = NULL, const uint8 *xmapPtr = NULL);
 	int isWizPixelNonTransparent(const uint8 *data, int x, int y, int w, int h);
 	uint8 getWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 color);
 	uint8 getRawWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 color);

Index: wiz_he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/wiz_he.cpp,v
retrieving revision 2.98
retrieving revision 2.99
diff -u -d -r2.98 -r2.99
--- wiz_he.cpp	18 Oct 2005 19:16:17 -0000	2.98
+++ wiz_he.cpp	21 Oct 2005 01:34:41 -0000	2.99
@@ -311,11 +311,11 @@
 	return srcRect.isValidRect() && dstRect.isValidRect();
 }
 
-void Wiz::copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, const uint8 *palPtr) {
+void Wiz::copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, const uint8 *palPtr, const uint8 *xmapPtr) {
 	Common::Rect r1, r2;
 	if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) {
 		dst += r2.left + r2.top * dstw;
-		decompressWizImage(dst, dstw, r2, src, r1, palPtr);
+		decompressWizImage(dst, dstw, r2, src, r1, palPtr, xmapPtr);
 	}
 }
 
@@ -406,7 +406,7 @@
 	}
 }
 
-void Wiz::decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect, const uint8 *palPtr) {
+void Wiz::decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect, const uint8 *palPtr, const uint8 *xmapPtr) {
 	const uint8 *dataPtr, *dataPtrNext;
 	uint8 *dstPtr, *dstPtrNext;
 	uint32 code;
@@ -496,16 +496,25 @@
 					if (w < 0) {
 						code += w;
 					}
-					uint8 color = palPtr[*dataPtr++];
-					memset(dstPtr, color, code);
-					dstPtr += code;
+					while (code--) {
+						if (xmapPtr) {
+							*dstPtr++ = xmapPtr[palPtr[*dataPtr] * 256 + *dstPtr];
+						} else {
+							*dstPtr++ = palPtr[*dataPtr];
+						}
+					}
+					*dataPtr++;
 				} else {
 dec_sub3:			w -= code;
 					if (w < 0) {
 						code += w;
 					}
 					while (code--) {
-						*dstPtr++ = palPtr[*dataPtr++];
+						if (xmapPtr) {
+							*dstPtr++ = xmapPtr[palPtr[*dataPtr++] * 256 + *dstPtr];
+						} else {
+							*dstPtr++ = palPtr[*dataPtr++];
+						}
 					}
 				}
 			}
@@ -935,6 +944,7 @@
 
 uint8 *Wiz::drawWizImage(int resNum, int state, int x1, int y1, int zorder, int shadow, int field_390, const Common::Rect *clipBox, int flags, int dstResNum, int palette) {
 	debug(2, "drawWizImage(resNum %d, x1 %d y1 %d flags 0x%X zorder %d shadow %d field_390 %d dstResNum %d palette %d)", resNum, x1, y1, flags, zorder, shadow, field_390, dstResNum, palette);
+	uint8 *dataPtr;
 	uint8 *dst = NULL;
 
 	const uint8 *palPtr = NULL;
@@ -946,12 +956,15 @@
 		}
 	}
 
-	const uint8 *xmap = NULL;
+	const uint8 *xmapPtr = NULL;
 	if (shadow) {
-		// TODO: Handle 'XMAP' data for shadows
+		dataPtr = _vm->getResourceAddress(rtImage, shadow);
+		assert(dataPtr);
+		xmapPtr = _vm->findResourceData(MKID('XMAP'), dataPtr);
+		assert(xmapPtr);
 	}
 
-	uint8 *dataPtr = _vm->getResourceAddress(rtImage, resNum);
+	dataPtr = _vm->getResourceAddress(rtImage, resNum);
 	assert(dataPtr);
 	
 	uint8 *wizh = _vm->findWrappedBlock(MKID('WIZH'), dataPtr, state, 0);
@@ -1028,9 +1041,6 @@
 		}
 	}
 
-	if (xmap) {
-		palPtr = xmap;
-	}
 	if (flags & kWIFRemapPalette) {
 		palPtr = rmap + 4;
 	}
@@ -1054,7 +1064,7 @@
 			// Used in readdemo
 			debug(0, "drawWizImage: Unhandled flag 0x100");
 		}
-		copyWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, palPtr);
+		copyWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, palPtr, xmapPtr);
 		break;
 	case 2:
 		copyRaw16BitWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, color);





More information about the Scummvm-git-logs mailing list