From ca6cf0eaf2692ac5c787b86e193e8e6980d2b7ee Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 15 Mar 2014 18:52:44 -0400 Subject: MADS: Fix display of user interface during animation --- engines/mads/mads.h | 1 - engines/mads/msurface.cpp | 16 ++++++++++++++-- engines/mads/msurface.h | 8 ++++++++ engines/mads/user_interface.cpp | 5 +++-- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/engines/mads/mads.h b/engines/mads/mads.h index 10f4badf75..f19abb3889 100644 --- a/engines/mads/mads.h +++ b/engines/mads/mads.h @@ -39,7 +39,6 @@ #include "mads/msurface.h" #include "mads/resources.h" #include "mads/sound.h" -#include "mads/user_interface.h" /** * This is the namespace of the MADS engine. diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp index c8c66234cb..62807e5543 100644 --- a/engines/mads/msurface.cpp +++ b/engines/mads/msurface.cpp @@ -34,20 +34,32 @@ MADSEngine *MSurface::_vm = nullptr; MSurface::MSurface() { pixels = nullptr; + _freeFlag = false; } MSurface::MSurface(int width, int height) { pixels = nullptr; + _freeFlag = false; setSize(width, height); } MSurface::~MSurface() { - Graphics::Surface::free(); + if (_freeFlag) + Graphics::Surface::free(); } void MSurface::setSize(int width, int height) { - Graphics::Surface::free(); + if (_freeFlag) + Graphics::Surface::free(); Graphics::Surface::create(width, height, Graphics::PixelFormat::createFormatCLUT8()); + _freeFlag = true; +} + +void MSurface::setPixels(byte *pData, int horizSize, int vertSize) { + _freeFlag = false; + pixels = pData; + w = horizSize; + h = vertSize; } int MSurface::scaleValue(int value, int scale, int err) { diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index d5b8741188..37ab305fb0 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -50,6 +50,8 @@ struct SpriteInfo { * MADS graphics surface */ class MSurface : public Graphics::Surface { +private: + bool _freeFlag; protected: static MADSEngine *_vm; public: @@ -83,6 +85,12 @@ public: */ void setSize(int width, int height); + /** + * Sets the pixels the surface is associated with + * @remarks The surface will not free the data block + */ + void setPixels(byte *pData, int horizSize, int vertSize); + /** * Draws an arbitrary line on the screen using a specified color * @param startPos Starting position diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp index 6afbf4c09c..63a0ec0a80 100644 --- a/engines/mads/user_interface.cpp +++ b/engines/mads/user_interface.cpp @@ -39,6 +39,9 @@ void SceneNode::load(Common::SeekableReadStream *f) { UserInterface::UserInterface(MADSEngine *vm) : _vm(vm) { _category = CAT_NONE; _screenObjectsCount = 0; + + byte *pData = _vm->_screen.getBasePtr(0, MADS_SCREEN_HEIGHT - MADS_INTERFACE_HEIGHT); + setPixels(pData, MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT); } void UserInterface::load(const Common::String &resName) { @@ -61,7 +64,6 @@ void UserInterface::load(const Common::String &resName) { delete palStream; // set the size for the interface - setSize(MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT); Common::SeekableReadStream *pixelsStream = madsPack.getItemStream(1); pixelsStream->read(getData(), MADS_SCREEN_WIDTH * MADS_INTERFACE_HEIGHT); delete pixelsStream; @@ -84,7 +86,6 @@ void UserInterface::setup(int id) { resName += "A"; resName += ".INT"; - free(); load(resName); } scene._screenObjects._v832EC = id; -- cgit v1.2.3