Made disk code directly create mask BitBuffer from resources.

svn-id: r28473
This commit is contained in:
Nicola Mettifogo 2007-08-06 19:39:00 +00:00
parent 57196e5dd8
commit 14448af3bb
3 changed files with 20 additions and 16 deletions

View file

@ -590,19 +590,19 @@ void DosDisk_ns::loadBackground(const char *filename) {
parseBackground(_resArchive); parseBackground(_resArchive);
byte *bg = (byte*)calloc(1, _vm->_screenSize); byte *bg = (byte*)calloc(1, _vm->_screenSize);
byte *mask = (byte*)calloc(1, _vm->_screenMaskSize); BitBuffer *mask = new BitBuffer;
mask->create(_vm->_screenWidth, _vm->_screenHeight);
byte *path = (byte*)calloc(1, _vm->_screenPathSize); byte *path = (byte*)calloc(1, _vm->_screenPathSize);
Graphics::PackBitsReadStream stream(_resArchive); Graphics::PackBitsReadStream stream(_resArchive);
unpackBackground(&stream, bg, mask, path); unpackBackground(&stream, bg, mask->data, path);
_vm->_gfx->setBackground(bg); _vm->_gfx->setBackground(bg);
_vm->_gfx->setMask(mask); _vm->_gfx->setMask(mask);
_vm->setPath(path); _vm->setPath(path);
free(bg); free(bg);
free(mask);
free(path); free(path);
return; return;
@ -621,15 +621,16 @@ void DosDisk_ns::loadMaskAndPath(const char *name) {
if (!_resArchive.openArchivedFile(path)) if (!_resArchive.openArchivedFile(path))
errorFileNotFound(name); errorFileNotFound(name);
byte *maskBuf = (byte*)calloc(1, _vm->_screenMaskSize); BitBuffer *mask = new BitBuffer;
mask->create(_vm->_screenWidth, _vm->_screenHeight);
byte *pathBuf = (byte*)calloc(1, _vm->_screenPathSize); byte *pathBuf = (byte*)calloc(1, _vm->_screenPathSize);
parseDepths(_resArchive); parseDepths(_resArchive);
_resArchive.read(pathBuf, _vm->_screenPathSize); _resArchive.read(pathBuf, _vm->_screenPathSize);
_resArchive.read(maskBuf, _vm->_screenMaskSize); _resArchive.read(mask->data, _vm->_screenMaskSize);
_vm->_gfx->setMask(maskBuf); _vm->_gfx->setMask(mask);
_vm->setPath(pathBuf); _vm->setPath(pathBuf);
return; return;
@ -1236,12 +1237,13 @@ void AmigaDisk_ns::loadMask(const char *name) {
s->seek(0x126, SEEK_SET); // HACK: skipping IFF/ILBM header should be done by analysis, not magic s->seek(0x126, SEEK_SET); // HACK: skipping IFF/ILBM header should be done by analysis, not magic
Graphics::PackBitsReadStream stream(*s); Graphics::PackBitsReadStream stream(*s);
byte *buf = (byte*)malloc(_vm->_screenMaskSize); BitBuffer *mask = new BitBuffer;
stream.read(buf, _vm->_screenMaskSize); mask->create(_vm->_screenWidth, _vm->_screenHeight);
buildMask(buf); stream.read(mask->data, _vm->_screenMaskSize);
buildMask(mask->data);
_vm->_gfx->setMask(mask);
_vm->_gfx->setMask(buf);
free(buf);
delete s; delete s;
return; return;

View file

@ -757,8 +757,11 @@ void Gfx::setBackground(byte *background) {
copyScreen(kBitBack, kBit2); copyScreen(kBitBack, kBit2);
} }
void Gfx::setMask(byte *mask) { void Gfx::setMask(BitBuffer *buffer) {
memcpy(_depthMask->data, mask, _vm->_screenMaskSize); if (_depthMask)
delete _depthMask;
_depthMask = buffer;
} }
@ -847,8 +850,7 @@ Gfx::Gfx(Parallaction* vm) :
_buffers[kBit2] = new Graphics::Surface; _buffers[kBit2] = new Graphics::Surface;
_buffers[kBit2]->create(_vm->_screenWidth, _vm->_screenHeight, 1); _buffers[kBit2]->create(_vm->_screenWidth, _vm->_screenHeight, 1);
_depthMask = new BitBuffer; _depthMask = 0;
_depthMask->create(_vm->_screenWidth, _vm->_screenHeight);
setBlackPalette(); setBlackPalette();

View file

@ -220,7 +220,7 @@ public:
// location // location
void setBackground(byte *background); void setBackground(byte *background);
void setMask(byte *mask); void setMask(BitBuffer *buffer);
int16 queryMask(int16 v); int16 queryMask(int16 v);
void intGrottaHackMask(); void intGrottaHackMask();
void restoreBackground(const Common::Rect& r); void restoreBackground(const Common::Rect& r);