Implemented raster operation for masks and postponed blitting of zones after everything in the location has been loaded. This fixes the remaining problems with animations not being masked by items.

svn-id: r33903
This commit is contained in:
Nicola Mettifogo 2008-08-15 15:08:08 +00:00
parent b4a2aee964
commit 7891e5afce
3 changed files with 28 additions and 14 deletions

View File

@ -264,8 +264,11 @@ void Parallaction::showZone(ZonePtr z, bool visible) {
GetData *data = z->u.get;
if (data->hasMask && _gfx->_backgroundInfo->hasMask) {
int frame = visible ? 0 : 1;
_gfx->_backgroundInfo->mask.blt(data->gfxobj->x, data->gfxobj->y, data->_mask[frame], 0, 0, data->_mask->w, data->_mask->h);
if (visible) {
_gfx->_backgroundInfo->mask.bltOr(data->gfxobj->x, data->gfxobj->y, data->_mask[0], 0, 0, data->_mask->w, data->_mask->h);
} else {
_gfx->_backgroundInfo->mask.bltCopy(data->gfxobj->x, data->gfxobj->y, data->_mask[1], 0, 0, data->_mask->w, data->_mask->h);
}
}
}
}

View File

@ -213,28 +213,38 @@ public:
return data + (x >> 2) + y * internalWidth;
}
void blt(uint16 dx, uint16 dy, const MaskBuffer &src, uint16 sx, uint16 sy, uint width, uint height) {
void bltOr(uint16 dx, uint16 dy, const MaskBuffer &src, uint16 sx, uint16 sy, uint width, uint height) {
assert((width <= w) && (width <= src.w) && (height <= h) && (height <= src.h));
byte *s = src.getPtr(sx, sy);
byte *d = getPtr(dx, dy);
uint diffs = 0;
// this code assumes buffers are aligned on 4-pixels boundaries, as the original does
uint16 linewidth = width >> 2;
for (uint16 i = 0; i < height; i++) {
for (uint16 j = 0; j < linewidth; j++) {
if (*s) diffs++;
*d++ |= *s++;
}
d += internalWidth - linewidth;
s += src.internalWidth - linewidth;
}
printf("MaskBuffer::blt() diffs = %i\n", diffs);
}
void bltCopy(uint16 dx, uint16 dy, const MaskBuffer &src, uint16 sx, uint16 sy, uint width, uint height) {
assert((width <= w) && (width <= src.w) && (height <= h) && (height <= src.h));
byte *s = src.getPtr(sx, sy);
byte *d = getPtr(dx, dy);
// this code assumes buffers are aligned on 4-pixels boundaries, as the original does
for (uint16 i = 0; i < height; i++) {
memcpy(d, s, (width >> 2));
d += internalWidth;
s += src.internalWidth;
}
}
};

View File

@ -793,7 +793,7 @@ void LocationParser_br::parseGetData(ZonePtr z) {
data->_mask[0].create(rect.width(), rect.height());
_vm->_disk->loadMask(_tokens[1], data->_mask[0]);
data->_mask[1].create(rect.width(), rect.height());
data->_mask[1].blt(0, 0, ctxt.info->mask, data->gfxobj->x, data->gfxobj->y, data->_mask->w, data->_mask->h);
data->_mask[1].bltCopy(0, 0, ctxt.info->mask, data->gfxobj->x, data->gfxobj->y, data->_mask->w, data->_mask->h);
data->hasMask = true;
} else {
warning("Mask for zone '%s' ignored, since background doesn't have one", z->_name);
@ -812,11 +812,6 @@ void LocationParser_br::parseGetData(ZonePtr z) {
} while (scumm_stricmp(_tokens[0], "endzone"));
z->u.get = data;
// FIXME: right now showZone doesn't work properly when called during location
// parsing. In fact, the main backgroundInfo is not properly set yet.
bool visible = (z->_flags & kFlagsRemove) == 0;
_vm->showZone(z, visible);
}
void LocationParser_br::parseZoneTypeBlock(ZonePtr z) {
@ -1252,6 +1247,12 @@ void LocationParser_br::parse(Script *script) {
_vm->_pathBuffer = &ctxt.info->path;
ZoneList::iterator it = _vm->_location._zones.begin();
for ( ; it != _vm->_location._zones.end(); it++) {
bool visible = ((*it)->_flags & kFlagsRemove) == 0;
_vm->showZone((*it), visible);
}
if (ctxt.characterName) {
_vm->changeCharacter(ctxt.characterName);
}