aboutsummaryrefslogtreecommitdiff
path: root/engines/toltecs/segmap.cpp
diff options
context:
space:
mode:
authorBenjamin Haisch2008-09-20 19:06:41 +0000
committerWillem Jan Palenstijn2011-11-20 22:43:06 +0100
commit7b97e8cd9370095b999b22371c1aef606a8464a1 (patch)
tree5b498423cef9e27432934da0b19794fbc1f2c038 /engines/toltecs/segmap.cpp
parent37a5f9e9ef9039808b225f598d02c1c48bc9fa95 (diff)
downloadscummvm-rg350-7b97e8cd9370095b999b22371c1aef606a8464a1.tar.gz
scummvm-rg350-7b97e8cd9370095b999b22371c1aef606a8464a1.tar.bz2
scummvm-rg350-7b97e8cd9370095b999b22371c1aef606a8464a1.zip
TOLTECS: A lot of changes in the graphics code:
- Optimized drawing code; now only items (sprites, text, screen masks) which have changed from the previous frame are redrawn, this speeds up things a lot - Implemented dirty rectangles using a microtile array - The previously committed Microtile Array implementation from SEL seemed buggy so I wrote my own version which works nicely so far (and is less code and GPL), only MicroTileArray::getRectangles uses parts from the old version, this will be changed later - One known bug related to dirty rectangles remains: Sometimes the background isn't restored correctly and gfx artifacts are visible
Diffstat (limited to 'engines/toltecs/segmap.cpp')
-rw-r--r--engines/toltecs/segmap.cpp74
1 files changed, 3 insertions, 71 deletions
diff --git a/engines/toltecs/segmap.cpp b/engines/toltecs/segmap.cpp
index 6a3f849d4a..ec9d021260 100644
--- a/engines/toltecs/segmap.cpp
+++ b/engines/toltecs/segmap.cpp
@@ -36,6 +36,7 @@
#include "sound/mixer.h"
#include "toltecs/toltecs.h"
+#include "toltecs/render.h"
#include "toltecs/resource.h"
#include "toltecs/screen.h"
#include "toltecs/segmap.h"
@@ -421,78 +422,9 @@ void SegmentMap::freeSegmapMaskRectSurfaces() {
}
}
-void SegmentMap::restoreMasksBySprite(SpriteDrawItem *sprite) {
- // TODO: This needs more optimization
+void SegmentMap::addMasksToRenderQueue() {
for (uint i = 0; i < _maskRects.size(); i++) {
- if (sprite->priority <= _maskRects[i].priority) {
- restoreMask(i);
- }
- }
-}
-
-void SegmentMap::restoreMask(int16 index) {
-
- // TODO: This needs more optimization
- SegmapMaskRect *maskRect = &_maskRects[index];
-
- int16 skipX = 0;
- int16 x = maskRect->x - _vm->_cameraX;
- int16 y = maskRect->y - _vm->_cameraY;
- int16 width = maskRect->width;
- int16 height = maskRect->height;
- byte *maskSurface = (byte*)maskRect->surface->getBasePtr(0, 0);
- byte *frontScreen;
-
- debug(0, "SegmentMap::restoreMask() screenX = %d; screenY = %d; maskX = %d; maskY = %d",
- x, y, maskRect->x, maskRect->y);
-
- // Not on screen, skip
- if (x + width < 0 || y + height < 0 || x >= 640 || y >= _vm->_cameraHeight)
- return;
-
- if (x < 0) {
- skipX = -x;
- x = 0;
- width -= skipX;
- }
-
- if (y < 0) {
- int16 skipY = -y;
- maskSurface += maskRect->width * skipY;
- y = 0;
- height -= skipY;
- }
-
- if (x + width >= 640) {
- width -= x + width - 640;
- }
-
- if (y + height >= _vm->_cameraHeight) {
- height -= y + height - _vm->_cameraHeight;
- }
-
- frontScreen = _vm->_screen->_frontScreen + x + (y * 640);
-
- for (int16 h = 0; h < height; h++) {
- maskSurface += skipX;
- for (int16 w = 0; w < width; w++) {
- if (*maskSurface != 0xFF)
- *frontScreen = *maskSurface;
- frontScreen++;
- maskSurface++;
- }
- frontScreen += 640 - width;
- maskSurface += maskRect->width - width - skipX;
- }
-
-}
-
-void SegmentMap::debugDrawRects(Graphics::Surface *surf) {
- for (uint16 i = 0; i < _pathRects.size(); i++) {
- SegmapPathRect pathRect = _pathRects[i];
- surf->frameRect(
- Common::Rect(pathRect.x1, pathRect.y1, pathRect.x2, pathRect.y2),
- 255);
+ _vm->_screen->_renderQueue->addMask(_maskRects[i]);
}
}