aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph-Eugene Winzer2017-06-18 17:05:21 +0200
committerThierry Crozat2018-01-22 23:29:35 +0000
commit4f3f231afd98d63a2ebdbec94671549d0d68f46f (patch)
tree3fb924f03e6c0bd95f0314bcfdb32e704182f89f
parentddcfda7d020fd22c97ea271c48ae105d9285fba5 (diff)
downloadscummvm-rg350-4f3f231afd98d63a2ebdbec94671549d0d68f46f.tar.gz
scummvm-rg350-4f3f231afd98d63a2ebdbec94671549d0d68f46f.tar.bz2
scummvm-rg350-4f3f231afd98d63a2ebdbec94671549d0d68f46f.zip
SUPERNOVA: Adds Container for temporarily storing screen sections
-rw-r--r--engines/supernova/supernova.cpp37
-rw-r--r--engines/supernova/supernova.h29
2 files changed, 66 insertions, 0 deletions
diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp
index 6bd50f9572..bcc2347c30 100644
--- a/engines/supernova/supernova.cpp
+++ b/engines/supernova/supernova.cpp
@@ -431,4 +431,41 @@ Object *Inventory::get(size_t index) {
return NULL;
}
+ScreenBufferStack::ScreenBufferStack()
+ : _last(_buffer) {
+}
+
+void ScreenBufferStack::push(int x, int y, int width, int height, int pitch) {
+ if (_last == ARRAYEND(_buffer))
+ return;
+
+ byte *pixels = new byte[width * height];
+ const byte *screen = static_cast<byte *>(g_system->lockScreen()->getBasePtr(x, y));
+ for (int i = 0; i < height; ++i) {
+ Common::copy(screen, screen + width, pixels);
+ screen += pitch * i;
+ }
+ g_system->unlockScreen();
+
+ _last->_x = x;
+ _last->_y = y;
+ _last->_width = width;
+ _last->_height = height;
+ _last->_pitch = pitch;
+ _last->_pixels = pixels;
+
+ ++_last;
+}
+
+void ScreenBufferStack::restore() {
+ if (_last == _buffer)
+ return;
+
+ g_system->lockScreen()->copyRectToSurface(
+ _last->_pixels, _last->_width, _last->_x, _last->_y,
+ _last->_width, _last->_height);
+ g_system->unlockScreen();
+ --_last;
+}
+
}
diff --git a/engines/supernova/supernova.h b/engines/supernova/supernova.h
index 2844c2aa6f..f97cd401e9 100644
--- a/engines/supernova/supernova.h
+++ b/engines/supernova/supernova.h
@@ -37,6 +37,35 @@
namespace Supernova {
+struct ScreenBuffer {
+ ScreenBuffer()
+ : _x(0)
+ , _y(0)
+ , _width(0)
+ , _height(0)
+ , _pitch(0)
+ , _pixels(0)
+ {}
+
+ byte *_pixels;
+ int _x;
+ int _y;
+ int _width;
+ int _height;
+ int _pitch;
+};
+class ScreenBufferStack {
+public:
+ ScreenBufferStack();
+
+ void push(int x, int y, int width, int height, int pitch = 320);
+ void restore();
+
+private:
+ ScreenBuffer _buffer[8];
+ ScreenBuffer *_last;
+};
+
class SupernovaEngine : public Engine {
public:
SupernovaEngine(OSystem *syst);