aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjohndoe1232014-04-04 10:47:39 +0200
committerEugene Sandulenko2018-07-20 06:43:33 +0000
commit54bce3d37a852e0d3a674277ff09212a7adfc007 (patch)
tree8c04acffabe11b7894513cd16bc61a7fff4a8182
parent6d17b40796bf6ff91d4d036a33280e0ec27788f6 (diff)
downloadscummvm-rg350-54bce3d37a852e0d3a674277ff09212a7adfc007.tar.gz
scummvm-rg350-54bce3d37a852e0d3a674277ff09212a7adfc007.tar.bz2
scummvm-rg350-54bce3d37a852e0d3a674277ff09212a7adfc007.zip
ILLUSIONS: Move SpriteDecompressQueue to screen
-rw-r--r--engines/illusions/module.mk1
-rw-r--r--engines/illusions/screen.cpp109
-rw-r--r--engines/illusions/screen.h26
-rw-r--r--engines/illusions/spritedecompressqueue.cpp132
-rw-r--r--engines/illusions/spritedecompressqueue.h61
5 files changed, 132 insertions, 197 deletions
diff --git a/engines/illusions/module.mk b/engines/illusions/module.mk
index 6a31657cba..6933553b39 100644
--- a/engines/illusions/module.mk
+++ b/engines/illusions/module.mk
@@ -27,7 +27,6 @@ MODULE_OBJS := \
sequenceopcodes.o \
soundresource.o \
specialcode.o \
- spritedecompressqueue.o \
spritedrawqueue.o \
talkresource.o \
talkthread.o \
diff --git a/engines/illusions/screen.cpp b/engines/illusions/screen.cpp
index f89e4248a1..aa5b81c849 100644
--- a/engines/illusions/screen.cpp
+++ b/engines/illusions/screen.cpp
@@ -24,10 +24,116 @@
#include "illusions/screen.h"
#include "illusions/graphics.h"
#include "illusions/spritedrawqueue.h"
-#include "illusions/spritedecompressqueue.h"
namespace Illusions {
+// SpriteDecompressQueue
+
+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._width * item->_dimensions._height;
+ int processedSize = 0;
+ int xincr, x, xstart;
+ int yincr, y;
+
+ // Safeguard
+ if (item->_dimensions._width > item->_surface->w ||
+ item->_dimensions._height > item->_surface->h) {
+ debug("Incorrect frame dimensions (%d, %d <> %d, %d)",
+ item->_dimensions._width, item->_dimensions._height,
+ item->_surface->w, item->_surface->h);
+ return;
+ }
+
+ 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;
+ processedSize += runCount;
+ 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;
+ }
+ }
+ } else {
+ int copyCount = op + 1;
+ processedSize += copyCount;
+ 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;
+ }
+ }
+ }
+ }
+
+ *item->_drawFlags &= ~1;
+
+}
+
// Screen
Screen::Screen(IllusionsEngine *vm)
@@ -92,7 +198,6 @@ void Screen::drawSurface11(int16 destX, int16 destY, Graphics::Surface *surface,
for (int16 yc = 0; yc < h; ++yc) {
byte *src = (byte*)surface->getBasePtr(srcRect.left, srcRect.top + yc);
byte *dst = (byte*)_backSurface->getBasePtr(destX, destY + yc);
- //memcpy(dst, src, w * 2);
for (int16 xc = 0; xc < w; ++xc) {
uint16 pixel = READ_LE_UINT16(src);
if (pixel != _colorKey1)
diff --git a/engines/illusions/screen.h b/engines/illusions/screen.h
index 8fa95ecfa6..33a0de3986 100644
--- a/engines/illusions/screen.h
+++ b/engines/illusions/screen.h
@@ -24,12 +24,36 @@
#define ILLUSIONS_SCREEN_H
#include "illusions/spritedrawqueue.h"
-#include "illusions/spritedecompressqueue.h"
+#include "common/list.h"
#include "graphics/surface.h"
namespace Illusions {
class IllusionsEngine;
+class Screen;
+
+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);
+};
class Screen {
public:
diff --git a/engines/illusions/spritedecompressqueue.cpp b/engines/illusions/spritedecompressqueue.cpp
deleted file mode 100644
index c20b0dba28..0000000000
--- a/engines/illusions/spritedecompressqueue.cpp
+++ /dev/null
@@ -1,132 +0,0 @@
-/* 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._width * item->_dimensions._height;
- int processedSize = 0;
- int xincr, x, xstart;
- int yincr, y;
-
- // Safeguard
- if (item->_dimensions._width > item->_surface->w ||
- item->_dimensions._height > item->_surface->h) {
- debug("Incorrect frame dimensions (%d, %d <> %d, %d)",
- item->_dimensions._width, item->_dimensions._height,
- item->_surface->w, item->_surface->h);
- return;
- }
-
- 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;
- processedSize += runCount;
- 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;
- }
- }
- } else {
- int copyCount = op + 1;
- processedSize += copyCount;
- 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;
- }
- }
- }
- }
-
- *item->_drawFlags &= ~1;
-
-}
-
-} // End of namespace Illusions
diff --git a/engines/illusions/spritedecompressqueue.h b/engines/illusions/spritedecompressqueue.h
deleted file mode 100644
index ede1cf8afe..0000000000
--- a/engines/illusions/spritedecompressqueue.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* 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