diff options
Diffstat (limited to 'engines/supernova/supernova.cpp')
-rw-r--r-- | engines/supernova/supernova.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/engines/supernova/supernova.cpp b/engines/supernova/supernova.cpp index e0adc7f548..4a4ede6ff5 100644 --- a/engines/supernova/supernova.cpp +++ b/engines/supernova/supernova.cpp @@ -595,11 +595,13 @@ 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)); + _last->_pixels = new byte[width * height]; + byte *pixels = _last->_pixels; + const byte *screen = static_cast<const byte *>(g_system->lockScreen()->getBasePtr(x, y)); for (int i = 0; i < height; ++i) { Common::copy(screen, screen + width, pixels); - screen += pitch * i; + screen += pitch; + pixels += width; } g_system->unlockScreen(); @@ -608,7 +610,6 @@ void ScreenBufferStack::push(int x, int y, int width, int height, int pitch) { _last->_width = width; _last->_height = height; _last->_pitch = pitch; - _last->_pixels = pixels; ++_last; } @@ -617,11 +618,13 @@ void ScreenBufferStack::restore() { if (_last == _buffer) return; + --_last; g_system->lockScreen()->copyRectToSurface( _last->_pixels, _last->_width, _last->_x, _last->_y, _last->_width, _last->_height); g_system->unlockScreen(); - --_last; + + delete[] _last->_pixels; } |