diff options
author | johndoe123 | 2014-03-11 15:23:55 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2018-07-20 06:43:33 +0000 |
commit | 971c8a0a1ddbdeaee33cd3b0f7307a0db2b73b0a (patch) | |
tree | 68f0f1c3e1a88f781b651d82904158d0aa832192 | |
parent | ee59e736d38be2c2478af0587ec5e8ee5c992119 (diff) | |
download | scummvm-rg350-971c8a0a1ddbdeaee33cd3b0f7307a0db2b73b0a.tar.gz scummvm-rg350-971c8a0a1ddbdeaee33cd3b0f7307a0db2b73b0a.tar.bz2 scummvm-rg350-971c8a0a1ddbdeaee33cd3b0f7307a0db2b73b0a.zip |
ILLUSIONS: Start with SpriteDecompressQueue
-rw-r--r-- | engines/illusions/illusions.cpp | 1 | ||||
-rw-r--r-- | engines/illusions/module.mk | 1 | ||||
-rw-r--r-- | engines/illusions/spritedecompressqueue.cpp | 123 | ||||
-rw-r--r-- | engines/illusions/spritedecompressqueue.h | 61 |
4 files changed, 186 insertions, 0 deletions
diff --git a/engines/illusions/illusions.cpp b/engines/illusions/illusions.cpp index cc8a92ec6e..67887ad00b 100644 --- a/engines/illusions/illusions.cpp +++ b/engines/illusions/illusions.cpp @@ -28,6 +28,7 @@ #include "illusions/input.h" #include "illusions/updatefunctions.h" #include "illusions/spritedrawqueue.h" +#include "illusions/spritedecompressqueue.h" #include "audio/audiostream.h" #include "common/config-manager.h" diff --git a/engines/illusions/module.mk b/engines/illusions/module.mk index 0e095bd631..f470e88606 100644 --- a/engines/illusions/module.mk +++ b/engines/illusions/module.mk @@ -8,6 +8,7 @@ MODULE_OBJS := \ illusions.o \ input.o \ resourcesystem.o \ + spritedecompressqueue.o \ spritedrawqueue.o \ updatefunctions.o diff --git a/engines/illusions/spritedecompressqueue.cpp b/engines/illusions/spritedecompressqueue.cpp new file mode 100644 index 0000000000..01ebc740ee --- /dev/null +++ b/engines/illusions/spritedecompressqueue.cpp @@ -0,0 +1,123 @@ +/* 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. + * + */ + +#include "illusions/spritedecompressqueue.h" + +namespace Illusions { + +SpriteDecompressQueue::SpriteDecompressQueue() { +} + +SpriteDecompressQueue::~SpriteDecompressQueue() { +} + +void SpriteDecompressQueue::insert(byte *drawFlags, uint32 flags, uint32 field8, WidthHeight &dimensions, + byte *compressedPixels, Graphics::Surface *surface) { + SpriteDecompressQueueItem *item = new SpriteDecompressQueueItem(); + item->_drawFlags = drawFlags; + *item->_drawFlags &= 1; + item->_flags = flags; + item->_dimensions = dimensions; + item->_compressedPixels = compressedPixels; + item->_field8 = field8; + item->_surface = surface; + _queue.push_back(item); +} + +void SpriteDecompressQueue::decompressAll() { + SpriteDecompressQueueListIterator it = _queue.begin(); + while (it != _queue.end()) { + decompress(*it); + delete *it; + it = _queue.erase(it); + } +} + +void SpriteDecompressQueue::decompress(SpriteDecompressQueueItem *item) { + byte *src = item->_compressedPixels; + Graphics::Surface *dstSurface = item->_surface; + int dstSize = item->_dimensions._height * item->_dimensions._width; + int processedSize = 0; + int xincr, x, xstart; + int yincr, y; + + if (item->_flags & 1) { + x = xstart = item->_dimensions._width - 1; + xincr = -1; + } else { + x = xstart = 0; + xincr = 1; + } + + if (item->_flags & 2) { + y = item->_dimensions._height - 1; + yincr = -1; + } else { + y = 0; + yincr = 1; + } + + byte *dst = (byte*)dstSurface->getBasePtr(x, y); + + while (processedSize < dstSize) { + int16 op = READ_LE_UINT16(src); + src += 2; + if (op & 0x8000) { + int runCount = (op & 0x7FFF) + 1; + uint16 runColor = READ_LE_UINT16(src); + src += 2; + while (runCount--) { + WRITE_LE_UINT16(dst, runColor); + x += xincr; + if (x >= item->_dimensions._width || x < 0) { + x = xstart; + y += yincr; + dst = (byte*)dstSurface->getBasePtr(x, y); + } else { + dst += 2 * xincr; + } + } + processedSize += runCount; + } else { + int copyCount = op + 1; + while (copyCount--) { + uint16 color = READ_LE_UINT16(src); + src += 2; + WRITE_LE_UINT16(dst, color); + x += xincr; + if (x >= item->_dimensions._width || x < 0) { + x = xstart; + y += yincr; + dst = (byte*)dstSurface->getBasePtr(x, y); + } else { + dst += 2 * xincr; + } + } + processedSize += copyCount; + } + } + + *item->_drawFlags &= ~1; + +} + +} // End of namespace Illusions diff --git a/engines/illusions/spritedecompressqueue.h b/engines/illusions/spritedecompressqueue.h new file mode 100644 index 0000000000..ede1cf8afe --- /dev/null +++ b/engines/illusions/spritedecompressqueue.h @@ -0,0 +1,61 @@ +/* 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. + * + */ + +#ifndef ILLUSIONS_SPRITEDECOMPRESSQUEUE_H +#define ILLUSIONS_SPRITEDECOMPRESSQUEUE_H + +#include "illusions/illusions.h" +#include "illusions/graphics.h" +#include "common/list.h" +#include "graphics/surface.h" + +namespace Illusions { + +struct SpriteDecompressQueueItem { + byte *_drawFlags; + uint32 _flags; + uint32 _field8; + WidthHeight _dimensions; + byte *_compressedPixels; + Graphics::Surface *_surface; +}; + +class SpriteDecompressQueue { +public: + SpriteDecompressQueue(); + ~SpriteDecompressQueue(); + void insert(byte *drawFlags, uint32 flags, uint32 field8, WidthHeight &dimensions, + byte *compressedPixels, Graphics::Surface *surface); + void decompressAll(); +protected: + typedef Common::List<SpriteDecompressQueueItem*> SpriteDecompressQueueList; + typedef SpriteDecompressQueueList::iterator SpriteDecompressQueueListIterator; + + SpriteDecompressQueueList _queue; + + void decompress(SpriteDecompressQueueItem *item); + +}; + +} // End of namespace Illusions + +#endif // ILLUSIONS_SPRITEDRAWQUEUE_H |