2009-10-03 20:49:18 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "sci/sci.h"
|
|
|
|
#include "sci/engine/state.h"
|
|
|
|
#include "sci/tools.h"
|
|
|
|
#include "sci/gui/gui_gfx.h"
|
|
|
|
#include "sci/gui/gui_screen.h"
|
|
|
|
#include "sci/gui/gui_view.h"
|
|
|
|
|
|
|
|
namespace Sci {
|
|
|
|
|
2009-10-05 07:10:01 +00:00
|
|
|
SciGuiView::SciGuiView(OSystem *system, EngineState *state, SciGuiGfx *gfx, SciGuiScreen *screen, GuiResourceId resourceId)
|
2009-10-03 20:49:18 +00:00
|
|
|
: _system(system), _s(state), _gfx(gfx), _screen(screen), _resourceId(resourceId) {
|
|
|
|
assert(resourceId != -1);
|
|
|
|
initData(resourceId);
|
|
|
|
}
|
|
|
|
|
2009-10-05 07:10:01 +00:00
|
|
|
SciGuiView::~SciGuiView() {
|
2009-10-03 20:49:18 +00:00
|
|
|
}
|
|
|
|
|
2009-10-04 22:15:19 +00:00
|
|
|
static const byte EGAMappingDefault[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
|
|
|
|
|
2009-10-05 07:10:01 +00:00
|
|
|
void SciGuiView::initData(GuiResourceId resourceId) {
|
2009-10-03 20:49:18 +00:00
|
|
|
Resource *viewResource = _s->resMan->findResource(ResourceId(kResourceTypeView, resourceId), false);
|
|
|
|
if (!viewResource) {
|
|
|
|
error("view resource %d not found", resourceId);
|
|
|
|
}
|
|
|
|
_resourceData = viewResource->data;
|
|
|
|
|
2009-10-05 07:10:01 +00:00
|
|
|
byte *celData, *loopData;
|
|
|
|
uint16 celOffset;
|
|
|
|
sciViewCelInfo *cel;
|
|
|
|
uint16 celCount = 0;
|
2009-10-03 20:49:18 +00:00
|
|
|
uint16 mirrorBits = 0;
|
|
|
|
uint16 palOffset = 0;
|
|
|
|
uint16 headerSize = 0;
|
2009-10-05 07:10:01 +00:00
|
|
|
uint16 loopSize = 0, celSize = 0;
|
|
|
|
int loopNo, celNo;
|
2009-10-03 20:49:18 +00:00
|
|
|
byte seekEntry;
|
2009-10-04 21:57:31 +00:00
|
|
|
bool IsEGA = false;
|
2009-10-03 20:49:18 +00:00
|
|
|
|
|
|
|
_embeddedPal = false;
|
2009-10-04 22:26:57 +00:00
|
|
|
_EGAMapping = EGAMappingDefault;
|
2009-10-03 20:49:18 +00:00
|
|
|
_loopCount = 0;
|
|
|
|
|
2009-10-04 21:30:13 +00:00
|
|
|
switch (_s->resMan->getViewType()) {
|
2009-10-04 21:57:31 +00:00
|
|
|
case kViewEga: // View-format SCI0
|
|
|
|
IsEGA = true;
|
2009-10-04 21:30:13 +00:00
|
|
|
case kViewVga: // View-format SCI1
|
2009-10-03 20:49:18 +00:00
|
|
|
// LoopCount:WORD MirrorMask:WORD Version:WORD PaletteOffset:WORD LoopOffset0:WORD LoopOffset1:WORD...
|
|
|
|
|
|
|
|
// bit 0x8000 of _resourceData[1] means palette is set
|
|
|
|
_loopCount = _resourceData[0];
|
|
|
|
mirrorBits = READ_LE_UINT16(_resourceData + 2);
|
|
|
|
palOffset = READ_LE_UINT16(_resourceData + 6);
|
|
|
|
|
|
|
|
if (palOffset && palOffset != 0x100) {
|
2009-10-04 22:15:19 +00:00
|
|
|
if (IsEGA) { // simple mapping for 16 colors
|
|
|
|
_EGAMapping = _resourceData + palOffset;
|
2009-10-04 21:57:31 +00:00
|
|
|
} else {
|
|
|
|
_gfx->CreatePaletteFromData(&_resourceData[palOffset], &_palette);
|
2009-10-04 22:15:19 +00:00
|
|
|
_embeddedPal = true;
|
2009-10-04 21:57:31 +00:00
|
|
|
}
|
2009-10-03 20:49:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_loop = new sciViewLoopInfo[_loopCount];
|
|
|
|
for (loopNo = 0; loopNo < _loopCount; loopNo++) {
|
|
|
|
loopData = _resourceData + READ_LE_UINT16(_resourceData + 8 + loopNo * 2);
|
2009-10-05 07:10:01 +00:00
|
|
|
// CelCount:WORD Unknown:WORD CelOffset0:WORD CelOffset1:WORD...
|
2009-10-03 20:49:18 +00:00
|
|
|
|
2009-10-05 07:10:01 +00:00
|
|
|
celCount = READ_LE_UINT16(loopData);
|
|
|
|
_loop[loopNo].celCount = celCount;
|
2009-10-03 20:49:18 +00:00
|
|
|
_loop[loopNo].mirrorFlag = mirrorBits & 1 ? true : false;
|
|
|
|
mirrorBits >>= 1;
|
|
|
|
|
|
|
|
// read cel info
|
2009-10-05 07:10:01 +00:00
|
|
|
_loop[loopNo].cel = new sciViewCelInfo[celCount];
|
|
|
|
for (celNo = 0; celNo < celCount; celNo++) {
|
|
|
|
celOffset = READ_LE_UINT16(loopData + 4 + celNo * 2);
|
|
|
|
celData = _resourceData + celOffset;
|
2009-10-03 20:49:18 +00:00
|
|
|
|
2009-10-04 21:57:31 +00:00
|
|
|
// For VGA
|
|
|
|
// Width:WORD Height:WORD DisplaceX:BYTE DisplaceY:BYTE ClearKey:BYTE Unknown:BYTE RLEData starts now directly
|
|
|
|
// For EGA
|
|
|
|
// Width:WORD Height:WORD DisplaceX:BYTE DisplaceY:BYTE ClearKey:BYTE EGAData starts now directly
|
2009-10-05 07:10:01 +00:00
|
|
|
cel = &_loop[loopNo].cel[celNo];
|
|
|
|
cel->width = READ_LE_UINT16(celData);
|
|
|
|
cel->height = READ_LE_UINT16(celData + 2);
|
|
|
|
cel->displaceX = celData[4];
|
|
|
|
cel->displaceY = celData[5];
|
2009-10-04 21:57:31 +00:00
|
|
|
if (IsEGA) {
|
2009-10-05 17:40:21 +00:00
|
|
|
cel->clearKey = celData[6] | celData[6] << 4;
|
2009-10-05 07:10:01 +00:00
|
|
|
cel->offsetEGA = celOffset + 7;
|
|
|
|
cel->offsetRLE = 0;
|
2009-10-04 21:57:31 +00:00
|
|
|
} else {
|
2009-10-05 17:40:21 +00:00
|
|
|
cel->clearKey = celData[6];
|
2009-10-05 07:10:01 +00:00
|
|
|
cel->offsetEGA = 0;
|
|
|
|
cel->offsetRLE = celOffset + 8;
|
2009-10-04 21:57:31 +00:00
|
|
|
}
|
2009-10-05 07:10:01 +00:00
|
|
|
cel->offsetLiteral = 0;
|
|
|
|
cel->rawBitmap = 0;
|
2009-10-03 20:49:18 +00:00
|
|
|
if (_loop[loopNo].mirrorFlag)
|
2009-10-05 07:10:01 +00:00
|
|
|
cel->displaceX = -cel->displaceX;
|
2009-10-03 20:49:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-10-04 21:30:13 +00:00
|
|
|
case kViewVga11: // View-format SCI1.1
|
2009-10-03 20:49:18 +00:00
|
|
|
// LoopCount:WORD MirrorMask:WORD Version:WORD PaletteOffset:WORD LoopOffset0:WORD LoopOffset1:WORD...
|
|
|
|
// HeaderSize:WORD LoopCount:WORD Version:WORD Unknown:WORD PaletteOffset:WORD
|
|
|
|
headerSize = READ_LE_UINT16(_resourceData + 0);
|
|
|
|
_loopCount = READ_LE_UINT16(_resourceData + 2);
|
|
|
|
palOffset = READ_LE_UINT16(_resourceData + 8);
|
|
|
|
|
|
|
|
loopData = _resourceData + headerSize;
|
|
|
|
loopSize = _resourceData[12];
|
2009-10-05 07:10:01 +00:00
|
|
|
celSize = _resourceData[13];
|
2009-10-03 20:49:18 +00:00
|
|
|
|
|
|
|
if (palOffset) {
|
2009-10-04 05:20:56 +00:00
|
|
|
_gfx->CreatePaletteFromData(&_resourceData[palOffset], &_palette);
|
2009-10-03 20:49:18 +00:00
|
|
|
_embeddedPal = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
_loop = new sciViewLoopInfo[_loopCount];
|
|
|
|
for (loopNo = 0; loopNo < _loopCount; loopNo++) {
|
|
|
|
loopData = _resourceData + headerSize + (loopNo * loopSize);
|
|
|
|
|
|
|
|
seekEntry = loopData[2];
|
|
|
|
if (seekEntry != 255) {
|
2009-10-05 17:57:06 +00:00
|
|
|
_loop[loopNo].mirrorFlag = true;
|
2009-10-03 20:49:18 +00:00
|
|
|
loopData = _resourceData + headerSize + (seekEntry * loopNo);
|
2009-10-05 17:57:06 +00:00
|
|
|
} else {
|
|
|
|
_loop[loopNo].mirrorFlag = false;
|
2009-10-03 20:49:18 +00:00
|
|
|
}
|
|
|
|
|
2009-10-05 07:10:01 +00:00
|
|
|
celCount = loopData[4];
|
|
|
|
_loop[loopNo].celCount = celCount;
|
2009-10-03 20:49:18 +00:00
|
|
|
|
2009-10-05 07:10:01 +00:00
|
|
|
celData = _resourceData + READ_LE_UINT16(loopData + 14);
|
2009-10-03 20:49:18 +00:00
|
|
|
|
|
|
|
// read cel info
|
2009-10-05 07:10:01 +00:00
|
|
|
_loop[loopNo].cel = new sciViewCelInfo[celCount];
|
|
|
|
for (celNo = 0; celNo < celCount; celNo++) {
|
|
|
|
cel = &_loop[loopNo].cel[celNo];
|
|
|
|
cel->width = READ_LE_UINT16(celData);
|
|
|
|
cel->height = READ_LE_UINT16(celData + 2);
|
|
|
|
cel->displaceX = READ_LE_UINT16(celData + 4);
|
|
|
|
cel->displaceY = READ_LE_UINT16(celData + 6);
|
|
|
|
cel->clearKey = celData[8];
|
|
|
|
cel->offsetEGA = 0;
|
|
|
|
cel->offsetRLE = READ_LE_UINT16(celData + 24);
|
|
|
|
cel->offsetLiteral = READ_LE_UINT16(celData + 28);
|
|
|
|
cel->rawBitmap = 0;
|
2009-10-03 20:49:18 +00:00
|
|
|
if (_loop[loopNo].mirrorFlag)
|
2009-10-05 07:10:01 +00:00
|
|
|
cel->displaceX = -cel->displaceX;
|
2009-10-03 20:49:18 +00:00
|
|
|
|
2009-10-05 07:10:01 +00:00
|
|
|
celData += celSize;
|
2009-10-03 20:49:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2009-10-04 21:30:13 +00:00
|
|
|
|
|
|
|
case kViewAmiga: // View-format on amiga
|
|
|
|
// FIXME
|
2009-10-04 21:57:31 +00:00
|
|
|
error("ViewType Amiga is currently unsupported");
|
2009-10-04 21:30:13 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
error("ViewType was not detected, can't continue");
|
2009-10-03 20:49:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-05 07:10:01 +00:00
|
|
|
GuiResourceId SciGuiView::getResourceId() {
|
2009-10-03 20:49:18 +00:00
|
|
|
return _resourceId;
|
|
|
|
}
|
|
|
|
|
2009-10-05 07:10:01 +00:00
|
|
|
int16 SciGuiView::getWidth(GuiViewLoopNo loopNo, GuiViewCelNo celNo) {
|
2009-10-03 20:49:18 +00:00
|
|
|
loopNo = CLIP<int16>(loopNo, 0, _loopCount -1);
|
2009-10-05 07:10:01 +00:00
|
|
|
if (celNo >= _loop[loopNo].celCount)
|
|
|
|
celNo = 0;
|
|
|
|
return _loopCount ? _loop[loopNo].cel[celNo].width : 0;
|
2009-10-03 20:49:18 +00:00
|
|
|
}
|
|
|
|
|
2009-10-05 07:10:01 +00:00
|
|
|
int16 SciGuiView::getHeight(GuiViewLoopNo loopNo, GuiViewCelNo celNo) {
|
2009-10-03 20:49:18 +00:00
|
|
|
loopNo = CLIP<int16>(loopNo, 0, _loopCount -1);
|
2009-10-05 07:10:01 +00:00
|
|
|
if (celNo >= _loop[loopNo].celCount)
|
|
|
|
celNo = 0;
|
|
|
|
return _loopCount ? _loop[loopNo].cel[celNo].height : 0;
|
2009-10-03 20:49:18 +00:00
|
|
|
}
|
|
|
|
|
2009-10-05 07:10:01 +00:00
|
|
|
sciViewCelInfo *SciGuiView::getCelInfo(GuiViewLoopNo loopNo, GuiViewCelNo celNo) {
|
2009-10-04 15:34:43 +00:00
|
|
|
loopNo = CLIP<int16>(loopNo, 0, _loopCount - 1);
|
2009-10-05 07:10:01 +00:00
|
|
|
if (celNo >= _loop[loopNo].celCount)
|
|
|
|
celNo = 0;
|
|
|
|
return _loopCount ? &_loop[loopNo].cel[celNo] : NULL;
|
2009-10-03 20:49:18 +00:00
|
|
|
}
|
|
|
|
|
2009-10-05 07:10:01 +00:00
|
|
|
sciViewLoopInfo *SciGuiView::getLoopInfo(GuiViewLoopNo loopNo) {
|
2009-10-04 15:34:43 +00:00
|
|
|
loopNo = CLIP<int16>(loopNo, 0, _loopCount - 1);
|
|
|
|
return _loopCount ? &_loop[loopNo] : NULL;
|
|
|
|
}
|
|
|
|
|
2009-10-05 07:10:01 +00:00
|
|
|
void SciGuiView::getCelRect(GuiViewLoopNo loopNo, GuiViewCelNo celNo, int16 x, int16 y, int16 z, Common::Rect *outRect) {
|
|
|
|
sciViewCelInfo *celInfo = getCelInfo(loopNo, celNo);
|
|
|
|
if (celInfo) {
|
|
|
|
outRect->left = x + celInfo->displaceX - (celInfo->width >> 1);
|
|
|
|
outRect->right = outRect->left + celInfo->width;
|
|
|
|
outRect->bottom = y + celInfo->displaceY - z + 1;
|
|
|
|
outRect->top = outRect->bottom - celInfo->height;
|
2009-10-04 15:34:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-05 07:10:01 +00:00
|
|
|
void SciGuiView::unpackCel(GuiViewLoopNo loopNo, GuiViewCelNo celNo, byte *outPtr, uint16 pixelCount) {
|
|
|
|
sciViewCelInfo *celInfo = getCelInfo(loopNo, celNo);
|
2009-10-04 21:57:31 +00:00
|
|
|
byte *rlePtr;
|
|
|
|
byte *literalPtr;
|
2009-10-05 16:51:01 +00:00
|
|
|
uint16 pixelNo = 0, runLength;
|
|
|
|
byte byte;
|
2009-10-03 20:49:18 +00:00
|
|
|
|
2009-10-05 07:10:01 +00:00
|
|
|
if (celInfo->offsetEGA) { // EGA data
|
|
|
|
literalPtr = _resourceData + _loop[loopNo].cel[celNo].offsetEGA;
|
2009-10-05 16:51:01 +00:00
|
|
|
while (pixelNo < pixelCount) {
|
|
|
|
byte = *literalPtr++;
|
|
|
|
runLength = byte >> 4;
|
|
|
|
byte = _EGAMapping[byte & 0x0F];
|
2009-10-05 17:40:21 +00:00
|
|
|
memset(outPtr + pixelNo, byte | byte << 4, MIN<uint16>(runLength, pixelCount - pixelNo));
|
2009-10-05 16:51:01 +00:00
|
|
|
pixelNo += runLength;
|
|
|
|
}
|
2009-10-04 21:57:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-05 07:10:01 +00:00
|
|
|
rlePtr = _resourceData + celInfo->offsetRLE;
|
|
|
|
if (!celInfo->offsetLiteral) { // no extra literal data
|
2009-10-03 20:49:18 +00:00
|
|
|
while (pixelNo < pixelCount) {
|
2009-10-05 16:51:01 +00:00
|
|
|
byte = *rlePtr++;
|
|
|
|
runLength = byte & 0x3F;
|
|
|
|
switch (byte & 0xC0) {
|
2009-10-03 20:49:18 +00:00
|
|
|
case 0: // copy bytes as-is
|
2009-10-05 16:51:01 +00:00
|
|
|
while (runLength-- && pixelNo < pixelCount)
|
2009-10-03 20:49:18 +00:00
|
|
|
outPtr[pixelNo++] = *rlePtr++;
|
|
|
|
break;
|
|
|
|
case 0x80: // fill with color
|
2009-10-05 16:51:01 +00:00
|
|
|
memset(outPtr + pixelNo, *rlePtr++, MIN<uint16>(runLength, pixelCount - pixelNo));
|
|
|
|
pixelNo += runLength;
|
2009-10-03 20:49:18 +00:00
|
|
|
break;
|
|
|
|
case 0xC0: // fill with transparent
|
2009-10-05 16:51:01 +00:00
|
|
|
pixelNo += runLength;
|
2009-10-03 20:49:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2009-10-05 07:10:01 +00:00
|
|
|
literalPtr = _resourceData + celInfo->offsetLiteral;
|
2009-10-03 20:49:18 +00:00
|
|
|
while (pixelNo < pixelCount) {
|
2009-10-05 16:51:01 +00:00
|
|
|
byte = *rlePtr++;
|
|
|
|
runLength = byte & 0x3F;
|
|
|
|
switch (byte & 0xC0) {
|
2009-10-03 20:49:18 +00:00
|
|
|
case 0: // copy bytes as-is
|
2009-10-05 16:51:01 +00:00
|
|
|
while (runLength-- && pixelNo < pixelCount)
|
2009-10-03 20:49:18 +00:00
|
|
|
outPtr[pixelNo++] = *literalPtr++;
|
|
|
|
break;
|
|
|
|
case 0x80: // fill with color
|
2009-10-05 16:51:01 +00:00
|
|
|
memset(outPtr + pixelNo, *literalPtr++, MIN<uint16>(runLength, pixelCount - pixelNo));
|
|
|
|
pixelNo += runLength;
|
2009-10-03 20:49:18 +00:00
|
|
|
break;
|
|
|
|
case 0xC0: // fill with transparent
|
2009-10-05 16:51:01 +00:00
|
|
|
pixelNo += runLength;
|
2009-10-03 20:49:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-05 07:10:01 +00:00
|
|
|
byte *SciGuiView::getBitmap(GuiViewLoopNo loopNo, GuiViewCelNo celNo) {
|
2009-10-03 20:49:18 +00:00
|
|
|
loopNo = CLIP<int16>(loopNo, 0, _loopCount -1);
|
2009-10-05 07:10:01 +00:00
|
|
|
if (celNo >= _loop[loopNo].celCount)
|
|
|
|
celNo = 0;
|
|
|
|
if (_loop[loopNo].cel[celNo].rawBitmap)
|
|
|
|
return _loop[loopNo].cel[celNo].rawBitmap;
|
2009-10-03 20:49:18 +00:00
|
|
|
|
2009-10-05 07:10:01 +00:00
|
|
|
uint16 width = _loop[loopNo].cel[celNo].width;
|
|
|
|
uint16 height = _loop[loopNo].cel[celNo].height;
|
2009-10-03 20:49:18 +00:00
|
|
|
// allocating memory to store cel's bitmap
|
|
|
|
assert(width * height <= 64000);
|
|
|
|
uint16 pixelCount = width * height;
|
2009-10-05 07:10:01 +00:00
|
|
|
_loop[loopNo].cel[celNo].rawBitmap = new byte[pixelCount];
|
|
|
|
byte *pOut = _loop[loopNo].cel[celNo].rawBitmap;
|
2009-10-03 20:49:18 +00:00
|
|
|
|
2009-10-04 21:57:31 +00:00
|
|
|
// Some RLE compressed cels end with the last non-transparent pixel, thats why we fill it up here
|
|
|
|
// FIXME: change this to fill the remaining bytes within unpackCel()
|
2009-10-05 07:10:01 +00:00
|
|
|
memset(pOut, _loop[loopNo].cel[celNo].clearKey, pixelCount);
|
|
|
|
unpackCel(loopNo, celNo, pOut, pixelCount);
|
2009-10-03 20:49:18 +00:00
|
|
|
|
2009-10-05 16:51:01 +00:00
|
|
|
// mirroring the cel if needed
|
2009-10-03 20:49:18 +00:00
|
|
|
if (_loop[loopNo].mirrorFlag) {
|
|
|
|
for (int i = 0; i < height; i++, pOut += width)
|
|
|
|
for (int j = 0; j < width / 2; j++)
|
|
|
|
SWAP(pOut[j], pOut[width - j - 1]);
|
|
|
|
}
|
2009-10-05 07:10:01 +00:00
|
|
|
return _loop[loopNo].cel[celNo].rawBitmap;
|
2009-10-03 20:49:18 +00:00
|
|
|
}
|
|
|
|
|
2009-10-05 07:10:01 +00:00
|
|
|
void SciGuiView::draw(Common::Rect rect, Common::Rect clipRect, GuiViewLoopNo loopNo, GuiViewCelNo celNo, byte priority, uint16 paletteNo) {
|
|
|
|
GuiPalette *palette = _embeddedPal ? &_palette : &_gfx->_sysPalette;
|
|
|
|
sciViewCelInfo *celInfo = getCelInfo(loopNo, celNo);
|
|
|
|
byte *bitmap = getBitmap(loopNo, celNo);
|
|
|
|
int16 celHeight = celInfo->height, celWidth = celInfo->width;
|
2009-10-03 20:49:18 +00:00
|
|
|
int16 width, height;
|
2009-10-05 07:10:01 +00:00
|
|
|
byte clearKey = celInfo->clearKey;
|
2009-10-03 20:49:18 +00:00
|
|
|
byte color;
|
|
|
|
byte drawMask = priority == 255 ? SCI_SCREEN_MASK_VISUAL : SCI_SCREEN_MASK_VISUAL|SCI_SCREEN_MASK_PRIORITY;
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
// Merge view palette in...
|
|
|
|
if (_embeddedPal)
|
|
|
|
_gfx->SetPalette(&_palette, 1);
|
|
|
|
|
2009-10-05 07:10:01 +00:00
|
|
|
width = MIN(clipRect.width(), celWidth);
|
|
|
|
height = MIN(clipRect.height(), celHeight);
|
2009-10-03 20:49:18 +00:00
|
|
|
|
2009-10-05 07:10:01 +00:00
|
|
|
bitmap += (clipRect.top - rect.top) * celWidth + (clipRect.left - rect.left);
|
2009-10-03 20:49:18 +00:00
|
|
|
_gfx->OffsetRect(clipRect);
|
|
|
|
|
2009-10-05 07:10:01 +00:00
|
|
|
for (y = clipRect.top; y < clipRect.top + height; y++, bitmap += celWidth) {
|
2009-10-03 20:49:18 +00:00
|
|
|
for (x = 0; x < width; x++) {
|
|
|
|
color = bitmap[x];
|
2009-10-05 07:38:05 +00:00
|
|
|
if (color != clearKey && priority >= _screen->getPriority(clipRect.left + x, y))
|
|
|
|
_screen->putPixel(clipRect.left + x, y, drawMask, palette->mapping[color], priority, 0);
|
2009-10-03 20:49:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-04 21:26:33 +00:00
|
|
|
} // End of namespace Sci
|