[Scummvm-cvs-logs] SF.net SVN: scummvm: [26861] scummvm/trunk/engines/cine
cyx at users.sourceforge.net
cyx at users.sourceforge.net
Fri May 18 00:13:32 CEST 2007
Revision: 26861
http://scummvm.svn.sourceforge.net/scummvm/?rev=26861&view=rev
Author: cyx
Date: 2007-05-17 15:13:31 -0700 (Thu, 17 May 2007)
Log Message:
-----------
added code for gfxSpriteFunc1 and gfxSpriteFunc2, which are used for sprite masking (see also bug #1624797)
Modified Paths:
--------------
scummvm/trunk/engines/cine/gfx.cpp
scummvm/trunk/engines/cine/gfx.h
scummvm/trunk/engines/cine/various.cpp
Modified: scummvm/trunk/engines/cine/gfx.cpp
===================================================================
--- scummvm/trunk/engines/cine/gfx.cpp 2007-05-17 17:59:27 UTC (rev 26860)
+++ scummvm/trunk/engines/cine/gfx.cpp 2007-05-17 22:13:31 UTC (rev 26861)
@@ -189,6 +189,84 @@
}
}
+// gfxDrawMaskedSprite
+void gfxSpriteFunc1(byte *spritePtr, byte *maskPtr, uint16 width, uint16 height, byte *page, int16 x, int16 y) {
+ int16 i, j;
+
+ for (i = 0; i < height; i++) {
+ byte *destPtr = page + x + y * 320;
+ destPtr += i * 320;
+
+ for (j = 0; j < width * 8; j++) {
+ if (x + j >= 0 && x + j < 320 && i + y >= 0 && i + y < 200 && *maskPtr == 0) {
+ *destPtr = *spritePtr;
+ }
+ ++destPtr;
+ ++spritePtr;
+ ++maskPtr;
+ }
+ }
+}
+
+// gfxUpdateSpriteMask
+void gfxSpriteFunc2(byte *spritePtr, byte *spriteMskPtr, int16 width, int16 height, byte *maskPtr,
+ int16 maskWidth, int16 maskHeight, byte *bufferSprPtr, byte *bufferMskPtr, int16 xs, int16 ys, int16 xm, int16 ym, byte maskIdx) {
+ int16 i, j, d, spritePitch, maskPitch;
+
+ width *= 8;
+ maskWidth *= 8;
+
+ spritePitch = width;
+ maskPitch = maskWidth;
+
+ if (maskIdx == 0) {
+ memcpy(bufferSprPtr, spritePtr, spritePitch * height);
+ memcpy(bufferMskPtr, spriteMskPtr, spritePitch * height);
+ }
+
+ if (ys > ym) {
+ d = ys - ym;
+ maskPtr += d * maskPitch;
+ maskHeight -= d;
+ }
+ if (maskHeight <= 0) {
+ return;
+ }
+ if (xs > xm) {
+ d = xs - xm;
+ maskPtr += d;
+ maskWidth -= d;
+ }
+ if (maskWidth <= 0) {
+ return;
+ }
+ if (ys < ym) {
+ d = ym - ys;
+ spriteMskPtr += d * spritePitch;
+ bufferMskPtr += d * spritePitch;
+ height -= d;
+ }
+ if (height <= 0) {
+ return;
+ }
+ if (xs < xm) {
+ d = xm - xs;
+ spriteMskPtr += d;
+ bufferMskPtr += d;
+ width -= d;
+ }
+ if (width <= 0) {
+ return;
+ }
+ for (j = 0; j < height; ++j) {
+ for (i = 0; i < width; ++i) {
+ bufferMskPtr[i] |= maskPtr[i] ^ 1;
+ }
+ bufferMskPtr += spritePitch;
+ maskPtr += maskPitch;
+ }
+}
+
void gfxDrawLine(int16 x1, int16 y1, int16 x2, int16 y2, byte color, byte *page) {
if (x1 == x2) {
if (y1 > y2) {
Modified: scummvm/trunk/engines/cine/gfx.h
===================================================================
--- scummvm/trunk/engines/cine/gfx.h 2007-05-17 17:59:27 UTC (rev 26860)
+++ scummvm/trunk/engines/cine/gfx.h 2007-05-17 22:13:31 UTC (rev 26861)
@@ -45,11 +45,11 @@
void transformPaletteRange(byte startColor, byte numColor, int8 r, int8 g, int8 b);
void gfxFlipPage(void);
-void gfxSpriteFunc1(byte *ptr, uint16 width, uint16 height, byte *page, int16 x, int16 y);
+void gfxSpriteFunc1(byte *ptr, byte *msk, uint16 width, uint16 height, byte *page, int16 x, int16 y);
void gfxFillSprite(byte *src4, uint16 sw, uint16 sh, byte *dst4, int16 sx, int16 sy);
-void gfxSpriteFunc2(byte *spritePtr, int16 width, int16 height, byte *maskPtr,
- int16 maskWidth, int16 maskHeight, byte *bufferPtr, int16 x, int16 y, byte maskIdx);
+void gfxSpriteFunc2(byte *spritePtr, byte *spriteMskPtr, int16 width, int16 height, byte *maskPtr,
+ int16 maskWidth, int16 maskHeight, byte *bufferSprPtr, byte *bufferMskPtr, int16 xs, int16 ys, int16 xm, int16 ym, byte maskIdx);
void gfxDrawLine(int16 x1, int16 y1, int16 x2, int16 y2, byte color, byte *page);
void gfxDrawPlainBox(int16 x1, int16 y1, int16 x2, int16 y2, byte color);
Modified: scummvm/trunk/engines/cine/various.cpp
===================================================================
--- scummvm/trunk/engines/cine/various.cpp 2007-05-17 17:59:27 UTC (rev 26860)
+++ scummvm/trunk/engines/cine/various.cpp 2007-05-17 22:13:31 UTC (rev 26861)
@@ -2188,13 +2188,18 @@
void drawSprite(overlayHeadElement *currentOverlay, byte *spritePtr,
byte *maskPtr, uint16 width, uint16 height, byte *page, int16 x, int16 y) {
-#if 0
byte *ptr = NULL;
+ byte *msk = NULL;
byte i = 0;
uint16 si = 0;
overlayHeadElement *pCurrentOverlay = currentOverlay;
- while (pCurrentOverlay) { // unfinished, probably for mask handling..
+ if (g_cine->getGameType() == Cine::GType_OS) {
+ drawSpriteRaw2(spritePtr, objectTable[currentOverlay->objIdx].part, width, height, page, x, y);
+ return;
+ }
+
+ while (pCurrentOverlay) {
if (pCurrentOverlay->type == 5) {
int16 maskX;
int16 maskY;
@@ -2203,7 +2208,8 @@
uint16 maskSpriteIdx;
if (!si) {
- ptr = (byte *)malloc(width * height);
+ ptr = (byte *)malloc(width * 8 * height);
+ msk = (byte *)malloc(width * 8 * height);
si = 1;
}
@@ -2214,25 +2220,19 @@
maskWidth = animDataTable[maskSpriteIdx].width / 2;
maskHeight = animDataTable[maskSpriteIdx].height;
-
- gfxSpriteFunc2(spritePtr, width, height, animDataTable[maskSpriteIdx].ptr1, maskWidth, maskHeight, ptr, maskX - x,maskY - y, i++);
+ gfxSpriteFunc2(spritePtr, maskPtr, width, height, animDataTable[maskSpriteIdx].ptr1, maskWidth, maskHeight, ptr, msk, x, y, maskX, maskY, i++);
}
pCurrentOverlay = pCurrentOverlay->next;
}
if (si) {
- gfxSpriteFunc1(ptr, width, height, page, x, y);
+ gfxSpriteFunc1(ptr, msk, width, height, page, x, y);
free(ptr);
- } else
-#endif
-
- if (g_cine->getGameType() == Cine::GType_OS) {
- drawSpriteRaw2(spritePtr, objectTable[currentOverlay->objIdx].part, width, height, page, x, y);
+ free(msk);
} else {
- drawSpriteRaw(spritePtr, maskPtr, width, height, page, x, y);
+ gfxSpriteFunc1(spritePtr, maskPtr, width, height, page, x, y);
}
-
}
int16 additionalBgVScroll = 0;
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