aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjohndoe1232014-04-04 10:53:00 +0200
committerEugene Sandulenko2018-07-20 06:43:33 +0000
commit6ba5570de52344da602cf02fb83725b468e3d8c5 (patch)
tree1e5cda64c460754c15b6b35534c596bbd2cea941
parent54bce3d37a852e0d3a674277ff09212a7adfc007 (diff)
downloadscummvm-rg350-6ba5570de52344da602cf02fb83725b468e3d8c5.tar.gz
scummvm-rg350-6ba5570de52344da602cf02fb83725b468e3d8c5.tar.bz2
scummvm-rg350-6ba5570de52344da602cf02fb83725b468e3d8c5.zip
ILLUSIONS: Move SpriteDrawQueue to screen
-rw-r--r--engines/illusions/module.mk1
-rw-r--r--engines/illusions/screen.cpp166
-rw-r--r--engines/illusions/screen.h43
-rw-r--r--engines/illusions/spritedrawqueue.cpp190
-rw-r--r--engines/illusions/spritedrawqueue.h81
5 files changed, 206 insertions, 275 deletions
diff --git a/engines/illusions/module.mk b/engines/illusions/module.mk
index 6933553b39..c4fe62b896 100644
--- a/engines/illusions/module.mk
+++ b/engines/illusions/module.mk
@@ -27,7 +27,6 @@ MODULE_OBJS := \
sequenceopcodes.o \
soundresource.o \
specialcode.o \
- spritedrawqueue.o \
talkresource.o \
talkthread.o \
thread.o \
diff --git a/engines/illusions/screen.cpp b/engines/illusions/screen.cpp
index aa5b81c849..de2efae4e9 100644
--- a/engines/illusions/screen.cpp
+++ b/engines/illusions/screen.cpp
@@ -22,8 +22,6 @@
#include "illusions/illusions.h"
#include "illusions/screen.h"
-#include "illusions/graphics.h"
-#include "illusions/spritedrawqueue.h"
namespace Illusions {
@@ -134,6 +132,170 @@ void SpriteDecompressQueue::decompress(SpriteDecompressQueueItem *item) {
}
+// SpriteDrawQueue
+
+SpriteDrawQueue::SpriteDrawQueue(Screen *screen)
+ : _screen(screen) {
+}
+
+SpriteDrawQueue::~SpriteDrawQueue() {
+}
+
+bool SpriteDrawQueue::draw(SpriteDrawQueueItem *item) {
+
+ // Check if the sprite has finished decompressing
+ if (item->_kind != 0 && (*item->_drawFlags & 1)) {
+ insert(item, item->_priority);
+ return false;
+ }
+
+ if (!_screen->isDisplayOn()) {
+ if (item->_drawFlags)
+ *item->_drawFlags &= ~4;
+ return true;
+ }
+
+ Common::Rect srcRect, dstRect;
+
+ // Check if the sprite is on-screen
+ if (!calcItemRect(item, srcRect, dstRect))
+ return true;
+
+ if (item->_scale == 100) {
+ if (item->_flags & 1)
+ _screen->drawSurface10(dstRect.left, dstRect.top, item->_surface, srcRect, _screen->getColorKey2());
+ else
+ _screen->drawSurface11(dstRect.left, dstRect.top, item->_surface, srcRect);
+ } else {
+ if (item->_flags & 1)
+ _screen->drawSurface20(dstRect, item->_surface, srcRect, _screen->getColorKey2());
+ else
+ _screen->drawSurface21(dstRect, item->_surface, srcRect);
+ }
+
+ if (item->_drawFlags)
+ *item->_drawFlags &= ~4;
+
+ return true;
+}
+
+void SpriteDrawQueue::drawAll() {
+ SpriteDrawQueueListIterator it = _queue.begin();
+ while (it != _queue.end()) {
+ if (draw(*it)) {
+ delete *it;
+ it = _queue.erase(it);
+ } else
+ ++it;
+ }
+}
+
+void SpriteDrawQueue::insertSprite(byte *drawFlags, Graphics::Surface *surface, WidthHeight &dimensions,
+ Common::Point &drawPosition, Common::Point &controlPosition, uint32 priority, int16 scale, uint16 flags) {
+ SpriteDrawQueueItem *item = new SpriteDrawQueueItem();
+ item->_drawFlags = drawFlags;
+ *item->_drawFlags &= 4;
+ item->_surface = surface;
+ item->_dimensions = dimensions;
+ item->_controlPosition = controlPosition;
+ item->_scale = scale;
+ item->_priority = priority;
+ item->_drawPosition = drawPosition;
+ item->_kind = 1;
+ item->_flags = flags;
+ insert(item, priority);
+}
+
+void SpriteDrawQueue::insertSurface(Graphics::Surface *surface, WidthHeight &dimensions,
+ Common::Point &drawPosition, uint32 priority) {
+ SpriteDrawQueueItem *item = new SpriteDrawQueueItem();
+ item->_surface = surface;
+ item->_dimensions = dimensions;
+ item->_drawFlags = 0;
+ item->_kind = 0;
+ item->_drawPosition.x = -drawPosition.x;
+ item->_drawPosition.y = -drawPosition.y;
+ item->_controlPosition.x = 0;
+ item->_controlPosition.y = 0;
+ item->_flags = 0;
+ item->_scale = 100;
+ item->_priority = priority;// << 16;
+ insert(item, priority);
+}
+
+void SpriteDrawQueue::insertTextSurface(Graphics::Surface *surface, WidthHeight &dimensions,
+ Common::Point &drawPosition, uint32 priority) {
+ SpriteDrawQueueItem *item = new SpriteDrawQueueItem();
+ item->_surface = surface;
+ item->_drawPosition = drawPosition;
+ item->_dimensions = dimensions;
+ item->_drawFlags = 0;
+ item->_kind = 0;
+ item->_controlPosition.x = 0;
+ item->_controlPosition.y = 0;
+ item->_flags = 0;
+ item->_priority = priority;
+ item->_scale = 100;
+ insert(item, priority);
+}
+
+void SpriteDrawQueue::insert(SpriteDrawQueueItem *item, uint32 priority) {
+ SpriteDrawQueueListIterator insertionPos = Common::find_if(_queue.begin(), _queue.end(),
+ FindInsertionPosition(priority));
+ _queue.insert(insertionPos, item);
+}
+
+bool SpriteDrawQueue::calcItemRect(SpriteDrawQueueItem *item, Common::Rect &srcRect, Common::Rect &dstRect) {
+
+ srcRect.left = 0;
+ srcRect.top = 0;
+ srcRect.right = item->_dimensions._width;
+ srcRect.bottom = item->_dimensions._height;
+
+ dstRect.left = item->_drawPosition.x - item->_scale * item->_controlPosition.x / 100;
+ dstRect.top = item->_drawPosition.y - item->_scale * item->_controlPosition.y / 100;
+ dstRect.right = item->_drawPosition.x + item->_scale * (item->_dimensions._width - item->_controlPosition.x) / 100;
+ dstRect.bottom = item->_drawPosition.y + item->_scale * (item->_dimensions._height - item->_controlPosition.y) / 100;
+
+ /* CHECKME This seems to be unused basically and only called from debug code
+ Left here just in case...
+ if (gfx_seemsAlways0) {
+ dstRect.left += screenOffsetPt.x;
+ dstRect.right = screenOffsetPt.x + dstRect.right;
+ dstRect.top = screenOffsetPt.y + dstRect.top;
+ dstRect.bottom = screenOffsetPt.y + dstRect.bottom;
+ }
+ */
+
+ // Check if the sprite is on-screen
+ if (dstRect.left >= 640 || dstRect.right <= 0 || dstRect.top >= 480 || dstRect.bottom <= 0)
+ return false;
+
+ // Clip the sprite rect if neccessary
+
+ if (dstRect.left < 0) {
+ srcRect.left += -100 * dstRect.left / item->_scale;
+ dstRect.left = 0;
+ }
+
+ if (dstRect.top < 0) {
+ srcRect.top += -100 * dstRect.top / item->_scale;
+ dstRect.top = 0;
+ }
+
+ if (dstRect.right > 640) {
+ srcRect.right += 100 * (640 - dstRect.right) / item->_scale;
+ dstRect.right = 640;
+ }
+
+ if (dstRect.bottom > 480) {
+ srcRect.bottom += 100 * (480 - dstRect.bottom) / item->_scale;
+ dstRect.bottom = 480;
+ }
+
+ return true;
+}
+
// Screen
Screen::Screen(IllusionsEngine *vm)
diff --git a/engines/illusions/screen.h b/engines/illusions/screen.h
index 33a0de3986..6332f7887f 100644
--- a/engines/illusions/screen.h
+++ b/engines/illusions/screen.h
@@ -23,8 +23,9 @@
#ifndef ILLUSIONS_SCREEN_H
#define ILLUSIONS_SCREEN_H
-#include "illusions/spritedrawqueue.h"
+#include "illusions/graphics.h"
#include "common/list.h"
+#include "common/rect.h"
#include "graphics/surface.h"
namespace Illusions {
@@ -55,6 +56,46 @@ protected:
void decompress(SpriteDecompressQueueItem *item);
};
+struct SpriteDrawQueueItem {
+ byte *_drawFlags;
+ int16 _kind;
+ int16 _scale;
+ uint16 _flags;
+ uint32 _priority;
+ Graphics::Surface *_surface;
+ WidthHeight _dimensions;
+ Common::Point _drawPosition;
+ Common::Point _controlPosition;
+};
+
+class SpriteDrawQueue {
+public:
+ SpriteDrawQueue(Screen *screen);
+ ~SpriteDrawQueue();
+ bool draw(SpriteDrawQueueItem *item);
+ void drawAll();
+ void insertSprite(byte *drawFlags, Graphics::Surface *surface, WidthHeight &dimensions,
+ Common::Point &drawPosition, Common::Point &controlPosition, uint32 priority, int16 scale, uint16 flags);
+ void insertSurface(Graphics::Surface *surface, WidthHeight &dimensions,
+ Common::Point &drawPosition, uint32 priority);
+ void insertTextSurface(Graphics::Surface *surface, WidthHeight &dimensions,
+ Common::Point &drawPosition, uint32 priority);
+protected:
+ typedef Common::List<SpriteDrawQueueItem*> SpriteDrawQueueList;
+ typedef SpriteDrawQueueList::iterator SpriteDrawQueueListIterator;
+ struct FindInsertionPosition : public Common::UnaryFunction<const SpriteDrawQueueItem*, bool> {
+ uint32 _priority;
+ FindInsertionPosition(uint32 priority) : _priority(priority) {}
+ bool operator()(const SpriteDrawQueueItem *item) const {
+ return item->_priority >= _priority;
+ }
+ };
+ Screen *_screen;
+ SpriteDrawQueueList _queue;
+ void insert(SpriteDrawQueueItem *item, uint32 priority);
+ bool calcItemRect(SpriteDrawQueueItem *item, Common::Rect &srcRect, Common::Rect &dstRect);
+};
+
class Screen {
public:
Screen(IllusionsEngine *vm);
diff --git a/engines/illusions/spritedrawqueue.cpp b/engines/illusions/spritedrawqueue.cpp
deleted file mode 100644
index d5a7394ac5..0000000000
--- a/engines/illusions/spritedrawqueue.cpp
+++ /dev/null
@@ -1,190 +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/spritedrawqueue.h"
-#include "illusions/screen.h"
-
-namespace Illusions {
-
-SpriteDrawQueue::SpriteDrawQueue(Screen *screen)
- : _screen(screen) {
-}
-
-SpriteDrawQueue::~SpriteDrawQueue() {
-}
-
-bool SpriteDrawQueue::draw(SpriteDrawQueueItem *item) {
-
- // Check if the sprite has finished decompressing
- if (item->_kind != 0 && (*item->_drawFlags & 1)) {
- insert(item, item->_priority);
- return false;
- }
-
- if (!_screen->isDisplayOn()) {
- if (item->_drawFlags)
- *item->_drawFlags &= ~4;
- return true;
- }
-
- Common::Rect srcRect, dstRect;
-
- // Check if the sprite is on-screen
- if (!calcItemRect(item, srcRect, dstRect))
- return true;
-
- if (item->_scale == 100) {
- if (item->_flags & 1)
- _screen->drawSurface10(dstRect.left, dstRect.top, item->_surface, srcRect, _screen->getColorKey2());
- else
- _screen->drawSurface11(dstRect.left, dstRect.top, item->_surface, srcRect);
- } else {
- if (item->_flags & 1)
- _screen->drawSurface20(dstRect, item->_surface, srcRect, _screen->getColorKey2());
- else
- _screen->drawSurface21(dstRect, item->_surface, srcRect);
- }
-
- if (item->_drawFlags)
- *item->_drawFlags &= ~4;
-
- return true;
-}
-
-void SpriteDrawQueue::drawAll() {
- SpriteDrawQueueListIterator it = _queue.begin();
- while (it != _queue.end()) {
- if (draw(*it)) {
- delete *it;
- it = _queue.erase(it);
- } else
- ++it;
- }
-}
-
-void SpriteDrawQueue::insertSprite(byte *drawFlags, Graphics::Surface *surface, WidthHeight &dimensions,
- Common::Point &drawPosition, Common::Point &controlPosition, uint32 priority, int16 scale, uint16 flags) {
- SpriteDrawQueueItem *item = new SpriteDrawQueueItem();
- item->_drawFlags = drawFlags;
- *item->_drawFlags &= 4;
- item->_surface = surface;
- item->_dimensions = dimensions;
- item->_controlPosition = controlPosition;
- item->_scale = scale;
- item->_priority = priority;
- item->_drawPosition = drawPosition;
- item->_kind = 1;
- item->_flags = flags;
- insert(item, priority);
-}
-
-void SpriteDrawQueue::insertSurface(Graphics::Surface *surface, WidthHeight &dimensions,
- Common::Point &drawPosition, uint32 priority) {
- SpriteDrawQueueItem *item = new SpriteDrawQueueItem();
- item->_surface = surface;
- item->_dimensions = dimensions;
- item->_drawFlags = 0;
- item->_kind = 0;
- item->_drawPosition.x = -drawPosition.x;
- item->_drawPosition.y = -drawPosition.y;
- item->_controlPosition.x = 0;
- item->_controlPosition.y = 0;
- item->_flags = 0;
- item->_scale = 100;
- item->_priority = priority;// << 16;
- insert(item, priority);
-}
-
-void SpriteDrawQueue::insertTextSurface(Graphics::Surface *surface, WidthHeight &dimensions,
- Common::Point &drawPosition, uint32 priority) {
- SpriteDrawQueueItem *item = new SpriteDrawQueueItem();
- item->_surface = surface;
- item->_drawPosition = drawPosition;
- item->_dimensions = dimensions;
- item->_drawFlags = 0;
- item->_kind = 0;
- item->_controlPosition.x = 0;
- item->_controlPosition.y = 0;
- item->_flags = 0;
- item->_priority = priority;
- item->_scale = 100;
- insert(item, priority);
-}
-
-void SpriteDrawQueue::insert(SpriteDrawQueueItem *item, uint32 priority) {
- SpriteDrawQueueListIterator insertionPos = Common::find_if(_queue.begin(), _queue.end(),
- FindInsertionPosition(priority));
- _queue.insert(insertionPos, item);
-}
-
-bool SpriteDrawQueue::calcItemRect(SpriteDrawQueueItem *item, Common::Rect &srcRect, Common::Rect &dstRect) {
-
- srcRect.left = 0;
- srcRect.top = 0;
- srcRect.right = item->_dimensions._width;
- srcRect.bottom = item->_dimensions._height;
-
- dstRect.left = item->_drawPosition.x - item->_scale * item->_controlPosition.x / 100;
- dstRect.top = item->_drawPosition.y - item->_scale * item->_controlPosition.y / 100;
- dstRect.right = item->_drawPosition.x + item->_scale * (item->_dimensions._width - item->_controlPosition.x) / 100;
- dstRect.bottom = item->_drawPosition.y + item->_scale * (item->_dimensions._height - item->_controlPosition.y) / 100;
-
- /* CHECKME This seems to be unused basically and only called from debug code
- Left here just in case...
- if (gfx_seemsAlways0) {
- dstRect.left += screenOffsetPt.x;
- dstRect.right = screenOffsetPt.x + dstRect.right;
- dstRect.top = screenOffsetPt.y + dstRect.top;
- dstRect.bottom = screenOffsetPt.y + dstRect.bottom;
- }
- */
-
- // Check if the sprite is on-screen
- if (dstRect.left >= 640 || dstRect.right <= 0 || dstRect.top >= 480 || dstRect.bottom <= 0)
- return false;
-
- // Clip the sprite rect if neccessary
-
- if (dstRect.left < 0) {
- srcRect.left += -100 * dstRect.left / item->_scale;
- dstRect.left = 0;
- }
-
- if (dstRect.top < 0) {
- srcRect.top += -100 * dstRect.top / item->_scale;
- dstRect.top = 0;
- }
-
- if (dstRect.right > 640) {
- srcRect.right += 100 * (640 - dstRect.right) / item->_scale;
- dstRect.right = 640;
- }
-
- if (dstRect.bottom > 480) {
- srcRect.bottom += 100 * (480 - dstRect.bottom) / item->_scale;
- dstRect.bottom = 480;
- }
-
- return true;
-}
-
-} // End of namespace Illusions
diff --git a/engines/illusions/spritedrawqueue.h b/engines/illusions/spritedrawqueue.h
deleted file mode 100644
index baa421704e..0000000000
--- a/engines/illusions/spritedrawqueue.h
+++ /dev/null
@@ -1,81 +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_SPRITEDRAWQUEUE_H
-#define ILLUSIONS_SPRITEDRAWQUEUE_H
-
-#include "illusions/illusions.h"
-#include "illusions/graphics.h"
-#include "common/list.h"
-#include "common/rect.h"
-#include "graphics/surface.h"
-
-namespace Illusions {
-
-class Screen;
-
-struct SpriteDrawQueueItem {
- byte *_drawFlags;
- int16 _kind;
- int16 _scale;
- uint16 _flags;
- //field_A dw
- uint32 _priority;
- Graphics::Surface *_surface;
- WidthHeight _dimensions;
- Common::Point _drawPosition;
- Common::Point _controlPosition;
-};
-
-class SpriteDrawQueue {
-public:
- SpriteDrawQueue(Screen *screen);
- ~SpriteDrawQueue();
- bool draw(SpriteDrawQueueItem *item);
- void drawAll();
- void insertSprite(byte *drawFlags, Graphics::Surface *surface, WidthHeight &dimensions,
- Common::Point &drawPosition, Common::Point &controlPosition, uint32 priority, int16 scale, uint16 flags);
- void insertSurface(Graphics::Surface *surface, WidthHeight &dimensions,
- Common::Point &drawPosition, uint32 priority);
- void insertTextSurface(Graphics::Surface *surface, WidthHeight &dimensions,
- Common::Point &drawPosition, uint32 priority);
-protected:
- typedef Common::List<SpriteDrawQueueItem*> SpriteDrawQueueList;
- typedef SpriteDrawQueueList::iterator SpriteDrawQueueListIterator;
-
- struct FindInsertionPosition : public Common::UnaryFunction<const SpriteDrawQueueItem*, bool> {
- uint32 _priority;
- FindInsertionPosition(uint32 priority) : _priority(priority) {}
- bool operator()(const SpriteDrawQueueItem *item) const {
- return item->_priority >= _priority;
- }
- };
-
- Screen *_screen;
- SpriteDrawQueueList _queue;
- void insert(SpriteDrawQueueItem *item, uint32 priority);
- bool calcItemRect(SpriteDrawQueueItem *item, Common::Rect &srcRect, Common::Rect &dstRect);
-};
-
-} // End of namespace Illusions
-
-#endif // ILLUSIONS_SPRITEDRAWQUEUE_H