From 077250acfb09afb67a445fad30aef6af2e2af014 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 10 Mar 2016 21:52:17 -0500 Subject: TSAGE: Changed engine to use Graphics::ManagedSurface --- engines/tsage/blue_force/blueforce_dialogs.cpp | 4 +- engines/tsage/blue_force/blueforce_logic.cpp | 4 +- engines/tsage/blue_force/blueforce_scenes6.cpp | 4 +- engines/tsage/converse.cpp | 2 +- engines/tsage/core.cpp | 10 +- engines/tsage/events.cpp | 4 +- engines/tsage/globals.cpp | 4 +- engines/tsage/globals.h | 3 +- engines/tsage/graphics.cpp | 292 ++++++------------------ engines/tsage/graphics.h | 30 +-- engines/tsage/module.mk | 1 + engines/tsage/ringworld/ringworld_dialogs.cpp | 6 +- engines/tsage/ringworld/ringworld_logic.cpp | 2 +- engines/tsage/ringworld/ringworld_scenes3.cpp | 6 +- engines/tsage/ringworld/ringworld_scenes5.cpp | 4 +- engines/tsage/ringworld2/ringworld2_dialogs.cpp | 2 +- engines/tsage/ringworld2/ringworld2_logic.cpp | 35 ++- engines/tsage/ringworld2/ringworld2_outpost.cpp | 2 +- engines/tsage/ringworld2/ringworld2_scenes0.cpp | 6 +- engines/tsage/saveload.cpp | 4 +- engines/tsage/scenes.cpp | 6 +- engines/tsage/screen.cpp | 46 ++++ engines/tsage/screen.h | 59 +++++ engines/tsage/tsage.h | 6 - engines/tsage/user_interface.cpp | 12 +- 25 files changed, 240 insertions(+), 314 deletions(-) create mode 100644 engines/tsage/screen.cpp create mode 100644 engines/tsage/screen.h (limited to 'engines') diff --git a/engines/tsage/blue_force/blueforce_dialogs.cpp b/engines/tsage/blue_force/blueforce_dialogs.cpp index 5be27c9ae7..3697ca700e 100644 --- a/engines/tsage/blue_force/blueforce_dialogs.cpp +++ b/engines/tsage/blue_force/blueforce_dialogs.cpp @@ -161,7 +161,7 @@ void RightClickDialog::execute() { } g_system->delayMillis(10); - GLOBALS._screenSurface.updateScreen(); + GLOBALS._screen.update(); } // Deactivate the graphics manager used for the dialog @@ -242,7 +242,7 @@ void AmmoBeltDialog::execute() { } g_system->delayMillis(10); - GLOBALS._screenSurface.updateScreen(); + GLOBALS._screen.update(); } _gfxManager.deactivate(); diff --git a/engines/tsage/blue_force/blueforce_logic.cpp b/engines/tsage/blue_force/blueforce_logic.cpp index e6e71399dc..2c5f9bd738 100644 --- a/engines/tsage/blue_force/blueforce_logic.cpp +++ b/engines/tsage/blue_force/blueforce_logic.cpp @@ -859,7 +859,7 @@ void SceneExt::endStrip() { } void SceneExt::clearScreen() { - BF_GLOBALS._screenSurface.fillRect(BF_GLOBALS._screenSurface.getBounds(), 0); + BF_GLOBALS._screen.clear(); } /*--------------------------------------------------------------------------*/ @@ -1411,7 +1411,7 @@ void SceneMessage::process(Event &event) { void SceneMessage::draw() { - GfxSurface &surface = BF_GLOBALS._screenSurface; + GfxSurface &surface = BF_GLOBALS._screen; // Clear the game area surface.fillRect(Rect(0, 0, SCREEN_WIDTH, UI_INTERFACE_Y), 0); diff --git a/engines/tsage/blue_force/blueforce_scenes6.cpp b/engines/tsage/blue_force/blueforce_scenes6.cpp index 92534d3095..0d6b5c2487 100644 --- a/engines/tsage/blue_force/blueforce_scenes6.cpp +++ b/engines/tsage/blue_force/blueforce_scenes6.cpp @@ -78,7 +78,7 @@ void Scene600::Action1::signal() { pObj->animate(ANIM_MODE_NONE, NULL); } - BF_GLOBALS._screenSurface.fillRect(BF_GLOBALS._screenSurface.getBounds(), 0); + BF_GLOBALS._screen.fillRect(BF_GLOBALS._screen.getBounds(), 0); scene->loadScene(999); setDelay(5); break; @@ -275,7 +275,7 @@ void Scene666::postInit(SceneObjectList *OwnerList) { SceneExt::postInit(); BF_GLOBALS._interfaceY = SCREEN_HEIGHT; loadScene(999); - BF_GLOBALS._screenSurface.fillRect(BF_GLOBALS._screenSurface.getBounds(), 0); + BF_GLOBALS._screen.fillRect(BF_GLOBALS._screen.getBounds(), 0); if (BF_GLOBALS._dayNumber == 0) { BF_GLOBALS._dayNumber = 1; diff --git a/engines/tsage/converse.cpp b/engines/tsage/converse.cpp index d1faca5dac..7240c91720 100644 --- a/engines/tsage/converse.cpp +++ b/engines/tsage/converse.cpp @@ -469,7 +469,7 @@ int ConversationChoiceDialog::execute(const Common::StringArray &choiceList) { while (!g_globals->_events.getEvent(event, EVENT_KEYPRESS | EVENT_BUTTON_DOWN | EVENT_MOUSE_MOVE) && !g_vm->shouldQuit()) { g_system->delayMillis(10); - GLOBALS._screenSurface.updateScreen(); + GLOBALS._screen.update(); } if (g_vm->shouldQuit()) break; diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp index d4068c25c9..985d16b031 100644 --- a/engines/tsage/core.cpp +++ b/engines/tsage/core.cpp @@ -1467,7 +1467,7 @@ void ScenePalette::fade(const byte *adjustData, bool fullAdjust, int percent) { // Set the altered palette g_system->getPaletteManager()->setPalette((const byte *)&tempPalette[0], 0, 256); - GLOBALS._screenSurface.updateScreen(); + GLOBALS._screen.update(); } PaletteRotation *ScenePalette::addRotation(int start, int end, int rotationMode, int duration, Action *action) { @@ -1524,11 +1524,11 @@ void ScenePalette::changeBackground(const Rect &bounds, FadeMode fadeMode) { if (g_vm->getGameID() != GType_Ringworld && g_vm->getGameID() != GType_Sherlock1) tempRect.setHeight(T2_GLOBALS._interfaceY); - g_globals->_screenSurface.copyFrom(g_globals->_sceneManager._scene->_backSurface, + g_globals->_screen.copyFrom(g_globals->_sceneManager._scene->_backSurface, tempRect, Rect(0, 0, tempRect.width(), tempRect.height()), NULL); if (g_vm->getGameID() == GType_Ringworld2 && !GLOBALS._player._uiEnabled && T2_GLOBALS._interfaceY == UI_INTERFACE_Y) { - g_globals->_screenSurface.fillRect(Rect(0, UI_INTERFACE_Y, SCREEN_WIDTH, SCREEN_HEIGHT - 1), 0); + g_globals->_screen.fillRect(Rect(0, UI_INTERFACE_Y, SCREEN_WIDTH, SCREEN_HEIGHT - 1), 0); } for (SynchronizedList::iterator i = tempPalette._listeners.begin(); i != tempPalette._listeners.end(); ++i) @@ -1796,7 +1796,7 @@ void SceneItem::display(int resNum, int lineNum, ...) { // Keep event on-screen until a mouse or keypress while (!g_vm->shouldQuit() && !g_globals->_events.getEvent(event, EVENT_BUTTON_DOWN | EVENT_KEYPRESS)) { - GLOBALS._screenSurface.updateScreen(); + GLOBALS._screen.update(); g_system->delayMillis(10); if ((g_vm->getGameID() == GType_Ringworld2) && (R2_GLOBALS._speechSubtitles & SPEECH_VOICE)) { @@ -2816,7 +2816,7 @@ void SceneObject::updateScreen() { destRect.translate(-sceneBounds.left, -sceneBounds.top); srcRect.translate(-g_globals->_sceneOffset.x, -g_globals->_sceneOffset.y); - g_globals->_screenSurface.copyFrom(g_globals->_sceneManager._scene->_backSurface, srcRect, destRect); + g_globals->_screen.copyFrom(g_globals->_sceneManager._scene->_backSurface, srcRect, destRect); } } diff --git a/engines/tsage/events.cpp b/engines/tsage/events.cpp index 0491c043a4..1fa17022de 100644 --- a/engines/tsage/events.cpp +++ b/engines/tsage/events.cpp @@ -50,7 +50,7 @@ bool EventsClass::pollEvent() { ++_frameNumber; // Update screen - GLOBALS._screenSurface.updateScreen(); + GLOBALS._screen.update(); } if (!g_system->getEventManager()->pollEvent(_event)) return false; @@ -400,7 +400,7 @@ void EventsClass::delay(int numFrames) { _priorFrameTime = g_system->getMillis(); } - GLOBALS._screenSurface.updateScreen(); + GLOBALS._screen.update(); _prevDelayFrame = _frameNumber; _priorFrameTime = g_system->getMillis(); } diff --git a/engines/tsage/globals.cpp b/engines/tsage/globals.cpp index b880f35007..b95bea3b23 100644 --- a/engines/tsage/globals.cpp +++ b/engines/tsage/globals.cpp @@ -59,7 +59,7 @@ static SavedObject *classFactoryProc(const Common::String &className) { /*--------------------------------------------------------------------------*/ -Globals::Globals() : _dialogCenter(160, 140), _gfxManagerInstance(_screenSurface), +Globals::Globals() : _dialogCenter(160, 140), _gfxManagerInstance(_screen), _randomSource("tsage"), _color1(0), _color2(255), _color3(255) { reset(); _stripNum = 0; @@ -119,7 +119,7 @@ Globals::Globals() : _dialogCenter(160, 140), _gfxManagerInstance(_screenSurface _color3 = 4; _dialogCenter.y = 100; } - _screenSurface.setScreenSurface(); + _gfxManagers.push_back(&_gfxManagerInstance); _sceneObjects = &_sceneObjectsInstance; diff --git a/engines/tsage/globals.h b/engines/tsage/globals.h index 1194fe8b9c..e1ebe261dc 100644 --- a/engines/tsage/globals.h +++ b/engines/tsage/globals.h @@ -30,6 +30,7 @@ #include "tsage/events.h" #include "tsage/sound.h" #include "tsage/saveload.h" +#include "tsage/screen.h" #include "tsage/user_interface.h" namespace TsAGE { @@ -38,7 +39,7 @@ class Globals : public SavedObject { private: static void dispatchSound(ASound *obj); public: - GfxSurface _screenSurface; + Screen _screen; GfxManager _gfxManagerInstance; Common::List _gfxManagers; SceneHandler *_sceneHandler; diff --git a/engines/tsage/graphics.cpp b/engines/tsage/graphics.cpp index 156503fb51..8620498c1e 100644 --- a/engines/tsage/graphics.cpp +++ b/engines/tsage/graphics.cpp @@ -229,123 +229,43 @@ void Rect::synchronize(Serializer &s) { /*--------------------------------------------------------------------------*/ -GfxSurface::GfxSurface() : _bounds(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) { +GfxSurface::GfxSurface() : Graphics::ManagedSurface(), _bounds(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) { _disableUpdates = false; _lockSurfaceCtr = 0; - _customSurface = NULL; _transColor = -1; - _trackDirtyRects = false; _flags = 0; } -GfxSurface::GfxSurface(const GfxSurface &s) { +GfxSurface::GfxSurface(const GfxSurface &s): Graphics::ManagedSurface() { _lockSurfaceCtr = 0; - _customSurface = NULL; - _trackDirtyRects = false; - *this = s; + + operator=(s); } GfxSurface::~GfxSurface() { - clear(); + // Sanity check.. GfxSurface should always be just referencing _rawSurface, + // and not directly managing it's own surface + assert(!isManaged()); } -void GfxSurface::clear() { - if (_customSurface) { - _customSurface->free(); - delete _customSurface; - _customSurface = NULL; - } -} - -/** - * Specifies that the surface will encapsulate the ScummVM screen surface - */ -void GfxSurface::setScreenSurface() { - _trackDirtyRects = true; - create(SCREEN_WIDTH, SCREEN_HEIGHT); -} - -/** - * Updates the physical screen with the screen surface buffer - */ -void GfxSurface::updateScreen() { - assert(_trackDirtyRects); - - // Merge any overlapping dirty rects - mergeDirtyRects(); - - // Loop through the dirty rect list to copy the affected areas to the sc - for (Common::List::iterator i = _dirtyRects.begin(); i != _dirtyRects.end(); ++i) { - Rect r = *i; - - // Make sure that there is something to update. If not, skip this - // rectangle. An example case is the speedbike closeup at the beginning - // of Ringworld (third screen). - if (r.isEmpty()) - continue; - - const byte *srcP = (const byte *)_customSurface->getBasePtr(r.left, r.top); - g_system->copyRectToScreen(srcP, _customSurface->pitch, r.left, r.top, - r.width(), r.height()); - } - - // Update the physical screen - g_system->updateScreen(); - - // Now that the dirty rects have been copied, clear the dirty rect list - _dirtyRects.clear(); -} +void GfxSurface::create(uint16 width, uint16 height) { + free(); -/** - * Adds a rect to the dirty rect list - */ -void GfxSurface::addDirtyRect(const Rect &r) { - if (_trackDirtyRects) { - // Get the bounds and adjust to allow for sub-screen areas - Rect r2 = r; - r2.translate(_bounds.left, _bounds.top); - - // Add to the dirty rect list - r2.right = MIN(r2.right + 1, SCREEN_WIDTH); - r2.bottom = MIN(r2.bottom + 1, SCREEN_HEIGHT); - - if (r2.isValidRect()) - _dirtyRects.push_back(r2); - } + _rawSurface.create(width, height); + setBounds(Rect(0, 0, width, height)); } - - -/** - * Specifies that the surface should maintain it's own internal surface - */ -void GfxSurface::create(int width, int height) { - assert((width >= 0) && (height >= 0)); - - if (_customSurface) { - _customSurface->free(); - delete _customSurface; - } - _customSurface = new Graphics::Surface(); - _customSurface->create(width, height, Graphics::PixelFormat::createFormatCLUT8()); - Common::fill((byte *)_customSurface->getPixels(), (byte *)_customSurface->getBasePtr(0, height), 0); - _bounds = Rect(0, 0, width, height); +void GfxSurface::setBounds(const Rect &bounds) { + _bounds = bounds; + Graphics::ManagedSurface::create(_rawSurface, bounds); } /** * Locks the surface for access, and returns a raw ScummVM surface to manipulate it */ -Graphics::Surface GfxSurface::lockSurface() { +Graphics::ManagedSurface &GfxSurface::lockSurface() { ++_lockSurfaceCtr; - - Graphics::Surface *src = _customSurface; - assert(src); - - // Setup the returned surface either as one pointing to the same pixels as the source, or - // as a subset of the source one based on the currently set bounds - Graphics::Surface result; - result.init(_bounds.width(), _bounds.height(), src->pitch, src->getBasePtr(_bounds.left, _bounds.top), src->format); - return result; + return *this; } /** @@ -367,69 +287,43 @@ void GfxSurface::synchronize(Serializer &s) { if (s.isSaving()) { // Save contents of the surface - if (_customSurface) { - s.syncAsSint16LE(_customSurface->w); - s.syncAsSint16LE(_customSurface->h); - s.syncBytes((byte *)_customSurface->getPixels(), _customSurface->w * _customSurface->h); + if (isManaged()) { + s.syncAsSint16LE(this->w); + s.syncAsSint16LE(this->h); + s.syncBytes((byte *)getPixels(), this->w * this->h); } else { int zero = 0; s.syncAsSint16LE(zero); s.syncAsSint16LE(zero); } } else { - int w = 0, h = 0; - s.syncAsSint16LE(w); - s.syncAsSint16LE(h); - - if ((w == 0) || (h == 0)) { - if (_customSurface) - delete _customSurface; - _customSurface = NULL; + int xSize = 0, ySize = 0; + s.syncAsSint16LE(xSize); + s.syncAsSint16LE(ySize); + + if (xSize == 0 || ySize == 0) { + free(); } else { - create(w, h); - s.syncBytes((byte *)_customSurface->getPixels(), w * h); + create(xSize, ySize); + s.syncBytes((byte *)getPixels(), xSize * ySize); } } } -/** - * Fills a specified rectangle on the surface with the specified color - * - * @bounds Area to fill - * @color Color to use - */ -void GfxSurface::fillRect(const Rect &bounds, int color) { - Graphics::Surface surface = lockSurface(); - surface.fillRect(bounds, color); - unlockSurface(); - addDirtyRect(bounds); -} - GfxSurface &GfxSurface::operator=(const GfxSurface &s) { assert(_lockSurfaceCtr == 0); assert(s._lockSurfaceCtr == 0); - if (_customSurface) { - _customSurface->free(); - delete _customSurface; - } - - _customSurface = s._customSurface; _disableUpdates = s._disableUpdates; _bounds = s._bounds; _centroid = s._centroid; _transColor = s._transColor; _flags = s._flags; - if (_customSurface) { - // Surface owns the internal data, so replicate it so new surface owns it's own - _customSurface = new Graphics::Surface(); - _customSurface->create(s._customSurface->w, s._customSurface->h, Graphics::PixelFormat::createFormatCLUT8()); - const byte *srcP = (const byte *)s._customSurface->getPixels(); - byte *destP = (byte *)_customSurface->getPixels(); - - Common::copy(srcP, srcP + (_bounds.width() * _bounds.height()), destP); - } + // Copy the source's surface + create(s.w, s.h); + blitFrom(s); + setBounds(s.getBounds()); return *this; } @@ -474,7 +368,7 @@ bool GfxSurface::displayText(const Common::String &msg, const Common::Point &pt) /** * Loads a quarter of a screen from a resource */ -void GfxSurface::loadScreenSection(Graphics::Surface &dest, int xHalf, int yHalf, int xSection, int ySection) { +void GfxSurface::loadScreenSection(Graphics::ManagedSurface &dest, int xHalf, int yHalf, int xSection, int ySection) { int screenNum = g_globals->_sceneManager._scene->_activeScreenNumber; Rect updateRect(0, 0, 160, 100); updateRect.translate(xHalf * 160, yHalf * 100); @@ -682,50 +576,6 @@ void GfxSurface::draw(const Common::Point &pt, Rect *rect) { } } -/** - * Merges any clipping rectangles that overlap to try and reduce - * the total number of clip rectangles. - */ -void GfxSurface::mergeDirtyRects() { - if (_dirtyRects.size() <= 1) - return; - - Common::List::iterator rOuter, rInner; - - for (rOuter = _dirtyRects.begin(); rOuter != _dirtyRects.end(); ++rOuter) { - rInner = rOuter; - while (++rInner != _dirtyRects.end()) { - - if ((*rOuter).intersects(*rInner)) { - // these two rectangles overlap or - // are next to each other - merge them - - unionRectangle(*rOuter, *rOuter, *rInner); - - // remove the inner rect from the list - _dirtyRects.erase(rInner); - - // move back to beginning of list - rInner = rOuter; - } - } - } -} - -/** - * Creates the union of two rectangles. - * Returns True if there is a union. - * @param pDest destination rectangle that is to receive the new union - * @param pSrc1 a source rectangle - * @param pSrc2 a source rectangle - */ -bool GfxSurface::unionRectangle(Common::Rect &destRect, const Rect &src1, const Rect &src2) { - destRect = src1; - destRect.extend(src2); - - return !destRect.isEmpty(); -} - /*--------------------------------------------------------------------------*/ GfxElement::GfxElement() { @@ -762,17 +612,16 @@ void GfxElement::highlight() { Rect tempRect(_bounds); tempRect.collapse(g_globals->_gfxEdgeAdjust - 1, g_globals->_gfxEdgeAdjust - 1); - for (int yp = tempRect.top; yp < tempRect.bottom; ++yp) { - byte *lineP = (byte *)surface.getBasePtr(tempRect.left, yp); - for (int xp = tempRect.left; xp < tempRect.right; ++xp, ++lineP) { + Graphics::Surface dest = surface.getSubArea(tempRect); + + for (int yp = 0; yp < dest.h; ++yp) { + byte *lineP = (byte *)dest.getBasePtr(0, yp); + for (int xp = 0; xp < tempRect.right; ++xp, ++lineP) { if (*lineP == _colors.background) *lineP = _colors.foreground; else if (*lineP == _colors.foreground) *lineP = _colors.background; } } - // Mark the affected area as dirty - gfxManager.getSurface().addDirtyRect(tempRect); - // Release the surface gfxManager.unlockSurface(); } @@ -816,10 +665,11 @@ void GfxElement::drawFrame() { // Loop through the surface area to replace each pixel // with its proper shaded replacement - Graphics::Surface surface = gfxManager.lockSurface(); - for (int y = tempRect.top; y < tempRect.bottom; ++y) { - byte *lineP = (byte *)surface.getBasePtr(tempRect.left, y); - for (int x = 0; x < tempRect.width(); ++x) { + Graphics::Surface dest = gfxManager.getSurface().getSubArea(tempRect); + + for (int y = 0; y < dest.h; ++y) { + byte *lineP = (byte *)dest.getBasePtr(0, y); + for (int x = 0; x < dest.w; ++x) { *lineP = transList[*lineP]; lineP++; } @@ -827,27 +677,24 @@ void GfxElement::drawFrame() { // Draw the edge frame // Outer frame border - surface.hLine(tempRect.left + 2, tempRect.top, tempRect.right - 2, 0); - surface.hLine(tempRect.left + 2, tempRect.bottom, tempRect.right - 2, 0); - surface.vLine(tempRect.left, tempRect.top + 2, tempRect.bottom - 2, 0); - surface.vLine(tempRect.right, tempRect.top + 2, tempRect.bottom - 2, 0); - *((byte *)surface.getBasePtr(tempRect.left + 1, tempRect.top + 1)) = 0; - *((byte *)surface.getBasePtr(tempRect.right - 1, tempRect.top + 1)) = 0; - *((byte *)surface.getBasePtr(tempRect.left + 1, tempRect.bottom - 1)) = 0; - *((byte *)surface.getBasePtr(tempRect.right - 1, tempRect.bottom - 1)) = 0; + dest.hLine(2, 0, dest.w - 2, 0); + dest.hLine(2, dest.h - 1, dest.w - 2, 0); + dest.vLine(0, 2, dest.h - 2, 0); + dest.vLine(tempRect.right, 2, dest.h - 2, 0); + *((byte *)dest.getBasePtr(1, 1)) = 0; + *((byte *)dest.getBasePtr(dest.w - 1, 1)) = 0; + *((byte *)dest.getBasePtr(1, dest.h - 1)) = 0; + *((byte *)dest.getBasePtr(dest.w - 1, dest.h - 1)) = 0; // Inner frame border - surface.hLine(tempRect.left + 2, tempRect.top + 1, tempRect.right - 2, R2_GLOBALS._frameEdgeColor); - surface.hLine(tempRect.left + 2, tempRect.bottom - 1, tempRect.right - 2, R2_GLOBALS._frameEdgeColor); - surface.vLine(tempRect.left + 1, tempRect.top + 2, tempRect.bottom - 2, R2_GLOBALS._frameEdgeColor); - surface.vLine(tempRect.right - 1, tempRect.top + 2, tempRect.bottom - 2, R2_GLOBALS._frameEdgeColor); - *((byte *)surface.getBasePtr(tempRect.left + 2, tempRect.top + 2)) = R2_GLOBALS._frameEdgeColor; - *((byte *)surface.getBasePtr(tempRect.right - 2, tempRect.top + 2)) = R2_GLOBALS._frameEdgeColor; - *((byte *)surface.getBasePtr(tempRect.left + 2, tempRect.bottom - 2)) = R2_GLOBALS._frameEdgeColor; - *((byte *)surface.getBasePtr(tempRect.right - 2, tempRect.bottom - 2)) = R2_GLOBALS._frameEdgeColor; - - gfxManager.unlockSurface(); - gfxManager.getSurface().addDirtyRect(tempRect); + dest.hLine(2, 1, dest.w - 2, R2_GLOBALS._frameEdgeColor); + dest.hLine(2, dest.h - 1, dest.w - 2, R2_GLOBALS._frameEdgeColor); + dest.vLine(1, 2, dest.h - 2, R2_GLOBALS._frameEdgeColor); + dest.vLine(dest.w - 1, 2, dest.h - 2, R2_GLOBALS._frameEdgeColor); + *((byte *)dest.getBasePtr(2, 2)) = R2_GLOBALS._frameEdgeColor; + *((byte *)dest.getBasePtr(dest.w - 2, 2)) = R2_GLOBALS._frameEdgeColor; + *((byte *)dest.getBasePtr(2, dest.h - 2)) = R2_GLOBALS._frameEdgeColor; + *((byte *)dest.getBasePtr(dest.w - 2, dest.h - 2)) = R2_GLOBALS._frameEdgeColor; } else { // Fill dialog content with specified background color @@ -1236,7 +1083,7 @@ GfxButton *GfxDialog::execute(GfxButton *defaultButton) { } g_system->delayMillis(10); - GLOBALS._screenSurface.updateScreen(); + GLOBALS._screen.update(); } _gfxManager.deactivate(); @@ -1269,7 +1116,7 @@ void GfxDialog::setPalette() { /*--------------------------------------------------------------------------*/ -GfxManager::GfxManager() : _surface(g_globals->_screenSurface), _oldManager(NULL) { +GfxManager::GfxManager() : _surface(g_globals->_screen), _oldManager(NULL) { _font.setOwner(this); _font._fillFlag = false; _bounds = Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); @@ -1563,23 +1410,24 @@ int GfxFont::writeChar(const char ch) { int yOffset = (_fontData[charOffset + 1] >> 3) & 0x1f; const uint8 *dataP = &_fontData[charOffset + 2]; - // Lock the surface for access - Graphics::Surface surfacePtr = _gfxManager->lockSurface(); - Rect charRect; charRect.set(0, 0, charWidth, _fontSize.y); charRect.translate(_topLeft.x + _position.x, _topLeft.y + _position.y + yOffset); + // Get the sub-section of the screen to update + Graphics::Surface dest = _gfxManager->getSurface().getSubArea(charRect); + if (_fillFlag) - surfacePtr.fillRect(charRect, _colors.background); + dest.fillRect(charRect, _colors.background); charRect.bottom = charRect.top + charHeight; + assert(charRect.height() <= dest.h); // Display the character int bitCtr = 0; uint8 v = 0; - for (int yp = charRect.top; yp < charRect.bottom; ++yp) { - byte *destP = (byte *)surfacePtr.getBasePtr(charRect.left, yp); + for (int yp = 0; yp < charHeight; ++yp) { + byte *destP = (byte *)dest.getBasePtr(0, yp); for (int xs = 0; xs < charRect.width(); ++xs, ++destP) { // Get the next color index to use @@ -1599,13 +1447,9 @@ int GfxFont::writeChar(const char ch) { } } - // Mark the affected area as dirty - _gfxManager->getSurface().addDirtyRect(charRect); - // Move the text writing position _position.x += charWidth; - _gfxManager->unlockSurface(); return charWidth; } diff --git a/engines/tsage/graphics.h b/engines/tsage/graphics.h index 25f7aea8cd..3b395b7625 100644 --- a/engines/tsage/graphics.h +++ b/engines/tsage/graphics.h @@ -28,7 +28,7 @@ #include "common/list.h" #include "common/rect.h" #include "common/system.h" -#include "graphics/surface.h" +#include "graphics/managed_surface.h" namespace TsAGE { @@ -73,20 +73,13 @@ public: enum FrameFlag { FRAME_FLIP_CENTROID_X = 4, FRAME_FLIP_CENTROID_Y = 8 }; -class GfxSurface { +class GfxSurface: virtual public Graphics::ManagedSurface { private: - Graphics::Surface *_customSurface; int _lockSurfaceCtr; + Graphics::ManagedSurface _rawSurface; bool _disableUpdates; Rect _bounds; - - bool _trackDirtyRects; - Common::List _dirtyRects; - - void mergeDirtyRects(); - bool unionRectangle(Common::Rect &destRect, const Rect &src1, const Rect &src2); - public: Common::Point _centroid; int _transColor; @@ -95,17 +88,13 @@ public: public: GfxSurface(); GfxSurface(const GfxSurface &s); - ~GfxSurface(); + virtual ~GfxSurface(); - void setScreenSurface(); - void updateScreen(); - void addDirtyRect(const Rect &r); - Graphics::Surface lockSurface(); + Graphics::ManagedSurface &lockSurface(); void unlockSurface(); void synchronize(Serializer &s); - void create(int width, int height); - void clear(); - void setBounds(const Rect &bounds) { _bounds = bounds; } + virtual void create(uint16 width, uint16 height); + void setBounds(const Rect &bounds); const Rect &getBounds() const { return _bounds; } void copyFrom(GfxSurface &src, Rect srcBounds, Rect destBounds, @@ -119,10 +108,9 @@ public: copyFrom(src, tempRect, priorityRegion); } void draw(const Common::Point &pt, Rect *rect = NULL); - void fillRect(const Rect &bounds, int color); GfxSurface &operator=(const GfxSurface &s); - static void loadScreenSection(Graphics::Surface &dest, int xHalf, int yHalf, int xSection, int ySection); + static void loadScreenSection(Graphics::ManagedSurface &dest, int xHalf, int yHalf, int xSection, int ySection); static bool displayText(const Common::String &msg, const Common::Point &pt = Common::Point(160, 100)); }; @@ -281,7 +269,7 @@ public: void getStringBounds(const char *s, Rect &bounds, int maxWidth); void setDialogPalette(); - Graphics::Surface lockSurface() { + Graphics::ManagedSurface lockSurface() { _surface.setBounds(_bounds); return _surface.lockSurface(); } diff --git a/engines/tsage/module.mk b/engines/tsage/module.mk index e23b157a95..b58c748567 100644 --- a/engines/tsage/module.mk +++ b/engines/tsage/module.mk @@ -47,6 +47,7 @@ MODULE_OBJS := \ ringworld2/ringworld2_vampire.o \ saveload.o \ scenes.o \ + screen.o \ sherlock/sherlock_logo.o \ sound.o \ staticres.o \ diff --git a/engines/tsage/ringworld/ringworld_dialogs.cpp b/engines/tsage/ringworld/ringworld_dialogs.cpp index 1dd3bc158b..9fa17f3920 100644 --- a/engines/tsage/ringworld/ringworld_dialogs.cpp +++ b/engines/tsage/ringworld/ringworld_dialogs.cpp @@ -181,7 +181,7 @@ void RightClickDialog::execute() { } g_system->delayMillis(10); - GLOBALS._screenSurface.updateScreen(); + GLOBALS._screen.update(); } _gfxManager.deactivate(); @@ -391,7 +391,7 @@ void InventoryDialog::execute() { Event event; while (!g_globals->_events.getEvent(event) && !g_vm->shouldQuit()) { g_system->delayMillis(10); - GLOBALS._screenSurface.updateScreen(); + GLOBALS._screen.update(); } if (g_vm->shouldQuit()) break; @@ -439,7 +439,7 @@ void InventoryDialog::execute() { // Inventory item selected InvObject *invObject = static_cast(hiliteObj)->_invObject; if (lookFlag) { - g_globals->_screenSurface.displayText(invObject->_description); + g_globals->_screen.displayText(invObject->_description); } else { RING_INVENTORY._selectedItem = invObject; invObject->setCursor(); diff --git a/engines/tsage/ringworld/ringworld_logic.cpp b/engines/tsage/ringworld/ringworld_logic.cpp index 1d8293cffd..354c86abfc 100644 --- a/engines/tsage/ringworld/ringworld_logic.cpp +++ b/engines/tsage/ringworld/ringworld_logic.cpp @@ -320,7 +320,7 @@ void SceneArea::wait() { // Wait until a mouse or keypress Event event; while (!g_vm->shouldQuit() && !g_globals->_events.getEvent(event)) { - GLOBALS._screenSurface.updateScreen(); + GLOBALS._screen.update(); g_system->delayMillis(10); } diff --git a/engines/tsage/ringworld/ringworld_scenes3.cpp b/engines/tsage/ringworld/ringworld_scenes3.cpp index a515224964..a9ed7af870 100644 --- a/engines/tsage/ringworld/ringworld_scenes3.cpp +++ b/engines/tsage/ringworld/ringworld_scenes3.cpp @@ -532,7 +532,7 @@ void Scene2100::Action1::signal() { // Wait for an event Event event; if (!g_globals->_events.getEvent(event)) { - GLOBALS._screenSurface.updateScreen(); + GLOBALS._screen.update(); g_system->delayMillis(10); continue; } @@ -2265,7 +2265,7 @@ void Scene2150::Action1::signal() { // Wait for an event Event event; if (!g_globals->_events.getEvent(event)) { - GLOBALS._screenSurface.updateScreen(); + GLOBALS._screen.update(); g_system->delayMillis(10); continue; } @@ -5119,7 +5119,7 @@ void Scene2320::Action3::signal() { // Wait for an event Event event; if (!g_globals->_events.getEvent(event)) { - GLOBALS._screenSurface.updateScreen(); + GLOBALS._screen.update(); g_system->delayMillis(10); continue; } diff --git a/engines/tsage/ringworld/ringworld_scenes5.cpp b/engines/tsage/ringworld/ringworld_scenes5.cpp index cb8a89de80..98859f32ee 100644 --- a/engines/tsage/ringworld/ringworld_scenes5.cpp +++ b/engines/tsage/ringworld/ringworld_scenes5.cpp @@ -2813,7 +2813,7 @@ void Scene4150::Action1::signal() { case 4: { for (int idx = 100; idx >= 0; idx -= 5) { g_globals->_scenePalette.fade(adjustData, false, idx); - GLOBALS._screenSurface.updateScreen(); + GLOBALS._screen.update(); g_system->delayMillis(10); } @@ -2841,7 +2841,7 @@ void Scene4150::Action1::signal() { case 7: for (int idx = 100; idx >= 0; idx -= 5) { g_globals->_scenePalette.fade(adjustData, false, idx); - GLOBALS._screenSurface.updateScreen(); + GLOBALS._screen.update(); g_system->delayMillis(10); } diff --git a/engines/tsage/ringworld2/ringworld2_dialogs.cpp b/engines/tsage/ringworld2/ringworld2_dialogs.cpp index 99f88a1687..027fb558db 100644 --- a/engines/tsage/ringworld2/ringworld2_dialogs.cpp +++ b/engines/tsage/ringworld2/ringworld2_dialogs.cpp @@ -154,7 +154,7 @@ int RightClickDialog::execute() { } g_system->delayMillis(10); - GLOBALS._screenSurface.updateScreen(); + GLOBALS._screen.update(); } // Execute the specified action diff --git a/engines/tsage/ringworld2/ringworld2_logic.cpp b/engines/tsage/ringworld2/ringworld2_logic.cpp index d24541932f..ecaa671bd7 100644 --- a/engines/tsage/ringworld2/ringworld2_logic.cpp +++ b/engines/tsage/ringworld2/ringworld2_logic.cpp @@ -351,7 +351,7 @@ SceneExt::SceneExt(): Scene() { _preventSaving = false; // Reset screen clipping area - R2_GLOBALS._screenSurface._clipRect = Rect(); + R2_GLOBALS._screen._clipRect = Rect(); // WORKAROUND: In the original, playing animations don't reset the global _animationCtr // counter as scene changes unless the playing animation explicitly finishes. For now, @@ -513,7 +513,7 @@ void SceneExt::endStrip() { } void SceneExt::clearScreen() { - R2_GLOBALS._screenSurface.fillRect(R2_GLOBALS._screenSurface.getBounds(), 0); + R2_GLOBALS._screen.fillRect(R2_GLOBALS._screen.getBounds(), 0); } void SceneExt::refreshBackground(int xAmount, int yAmount) { @@ -543,15 +543,12 @@ void SceneExt::refreshBackground(int xAmount, int yAmount) { int screenSize = g_vm->_memoryManager.getSize(dataP); // Lock the background for update - Graphics::Surface s = _backSurface.lockSurface(); - assert(screenSize == (s.w * s.h)); + assert(screenSize == (_backSurface.w * _backSurface.h)); + Graphics::Surface s = _backSurface.getSubArea(Common::Rect(0, 0, _backSurface.w, _backSurface.h)); - // Copy the data + // Copy the data into the surface byte *destP = (byte *)s.getPixels(); Common::copy(dataP, dataP + (s.w * s.h), destP); - _backSurface.unlockSurface(); - - R2_GLOBALS._screenSurface.addDirtyRect(_backSurface.getBounds()); // Free the resource data DEALLOCATE(dataP); @@ -601,7 +598,7 @@ void SceneExt::loadBlankScene() { _backSurface.create(SCREEN_WIDTH, SCREEN_HEIGHT * 3 / 2); _backSurface.fillRect(_backSurface.getBounds(), 0); - R2_GLOBALS._screenSurface.fillRect(R2_GLOBALS._screenSurface.getBounds(), 0); + R2_GLOBALS._screen.fillRect(R2_GLOBALS._screen.getBounds(), 0); } /*--------------------------------------------------------------------------*/ @@ -1966,10 +1963,9 @@ void AnimationPlayer::drawFrame(int sliceIndex) { byte *sliceData1 = sliceDataStart; Rect playerBounds = _screenBounds; - int y = _screenBounds.top; - R2_GLOBALS._screenSurface.addDirtyRect(playerBounds); - Graphics::Surface surface = R2_GLOBALS._screenSurface.lockSurface(); + Graphics::Surface dest = R2_GLOBALS._screen.getSubArea(playerBounds); + int y = 0; // Handle different drawing modes switch (slice._drawMode) { @@ -1980,7 +1976,7 @@ void AnimationPlayer::drawFrame(int sliceIndex) { // TODO: Check of _subData._drawType was done for two different kinds of // line slice drawing in original const byte *pSrc = (const byte *)sliceDataStart + READ_LE_UINT16(sliceData1 + sliceNum * 2); - byte *pDest = (byte *)surface.getBasePtr(playerBounds.left, y++); + byte *pDest = (byte *)dest.getBasePtr(0, y++); Common::copy(pSrc, pSrc + _subData._sliceSize, pDest); } @@ -1997,7 +1993,7 @@ void AnimationPlayer::drawFrame(int sliceIndex) { if (offset) { const byte *pSrc = (const byte *)sliceDataStart + offset; - byte *pDest = (byte *)surface.getBasePtr(playerBounds.left, playerBounds.top); + byte *pDest = (byte *)dest.getBasePtr(0, 0); //Common::copy(pSrc, pSrc + playerBounds.width(), pDest); rleDecode(pSrc, pDest, playerBounds.width()); @@ -2012,7 +2008,7 @@ void AnimationPlayer::drawFrame(int sliceIndex) { // TODO: Check of _subData._drawType was done for two different kinds of // line slice drawing in original const byte *pSrc = (const byte *)sliceDataStart + READ_LE_UINT16(sliceData1 + sliceNum * 2); - byte *pDest = (byte *)surface.getBasePtr(playerBounds.left, playerBounds.top); + byte *pDest = (byte *)dest.getBasePtr(0, 0); rleDecode(pSrc, pDest, _subData._sliceSize); } @@ -2027,7 +2023,7 @@ void AnimationPlayer::drawFrame(int sliceIndex) { for (int yIndex = 0; yIndex < _sliceHeight; ++yIndex) { const byte *pSrc1 = (const byte *)sliceDataStart + READ_LE_UINT16(sliceData2 + sliceNum * 2); const byte *pSrc2 = (const byte *)sliceDataStart + READ_LE_UINT16(sliceData1 + sliceNum * 2); - byte *pDest = (byte *)surface.getBasePtr(playerBounds.left, y++); + byte *pDest = (byte *)dest.getBasePtr(0, y++); if (slice2._drawMode == 0) { // Uncompressed background, foreground compressed @@ -2047,17 +2043,14 @@ void AnimationPlayer::drawFrame(int sliceIndex) { break; } - // Unlock the screen surface - R2_GLOBALS._screenSurface.unlockSurface(); - if (_objectMode == ANIMOBJMODE_42) { _screenBounds.expandPanes(); // Copy the drawn frame to the back surface - Rect srcRect = R2_GLOBALS._screenSurface.getBounds(); + Rect srcRect = R2_GLOBALS._screen.getBounds(); Rect destRect = srcRect; destRect.translate(-g_globals->_sceneOffset.x, -g_globals->_sceneOffset.y); - R2_GLOBALS._sceneManager._scene->_backSurface.copyFrom(R2_GLOBALS._screenSurface, + R2_GLOBALS._sceneManager._scene->_backSurface.copyFrom(R2_GLOBALS._screen, srcRect, destRect); // Draw any objects into the scene diff --git a/engines/tsage/ringworld2/ringworld2_outpost.cpp b/engines/tsage/ringworld2/ringworld2_outpost.cpp index cad21b4623..8c64970bda 100644 --- a/engines/tsage/ringworld2/ringworld2_outpost.cpp +++ b/engines/tsage/ringworld2/ringworld2_outpost.cpp @@ -4689,7 +4689,7 @@ GfxButton *Scene1337::OptionsDialog::execute(GfxButton *defaultButton) { } g_system->delayMillis(10); - GLOBALS._screenSurface.updateScreen(); + GLOBALS._screen.update(); } _gfxManager.deactivate(); diff --git a/engines/tsage/ringworld2/ringworld2_scenes0.cpp b/engines/tsage/ringworld2/ringworld2_scenes0.cpp index 573cbbb29a..63879b0366 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes0.cpp +++ b/engines/tsage/ringworld2/ringworld2_scenes0.cpp @@ -1613,7 +1613,7 @@ void Scene180::signal() { case 43: case 47: _helpEnabled = false; - R2_GLOBALS._screenSurface.fillRect(Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), 0); + R2_GLOBALS._screen.fillRect(Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), 0); _palette.loadPalette(0); _palette.loadPalette(9998); R2_GLOBALS._scenePalette.addFader(_palette._palette, 256, 8, this); @@ -1815,7 +1815,7 @@ void Scene180::signal() { _shipDisplay.remove(); _backSurface.fillRect(Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), 0); - R2_GLOBALS._screenSurface.fillRect(Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), 0); + R2_GLOBALS._screen.fillRect(Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), 0); R2_GLOBALS._sound2.fadeOut2(NULL); R2_GLOBALS._sound1.fadeOut2(this); break; @@ -1880,7 +1880,7 @@ void Scene180::signal() { R2_GLOBALS._paneRefreshFlag[0] = 3; _backSurface.fillRect(Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), 0); - R2_GLOBALS._screenSurface.fillRect(Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), 0); + R2_GLOBALS._screen.fillRect(Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), 0); setSceneDelay(1); break; diff --git a/engines/tsage/saveload.cpp b/engines/tsage/saveload.cpp index 9954b929b2..3cb8e52692 100644 --- a/engines/tsage/saveload.cpp +++ b/engines/tsage/saveload.cpp @@ -289,10 +289,10 @@ void Saver::writeSavegameHeader(Common::OutSaveFile *out, tSageSavegameHeader &h // Create a thumbnail and save it Graphics::Surface *thumb = new Graphics::Surface(); - Graphics::Surface s = g_globals->_screenSurface.lockSurface(); + Graphics::Surface s = g_globals->_screen.lockSurface(); ::createThumbnail(thumb, (const byte *)s.getPixels(), SCREEN_WIDTH, SCREEN_HEIGHT, thumbPalette); Graphics::saveThumbnail(*out, *thumb); - g_globals->_screenSurface.unlockSurface(); + g_globals->_screen.unlockSurface(); thumb->free(); delete thumb; diff --git a/engines/tsage/scenes.cpp b/engines/tsage/scenes.cpp index 80ce1e3ecc..095c0d7ab5 100644 --- a/engines/tsage/scenes.cpp +++ b/engines/tsage/scenes.cpp @@ -139,7 +139,7 @@ void SceneManager::fadeInIfNecessary() { percent = 100; g_globals->_scenePalette.fade((const byte *)&adjustData, false, percent); - GLOBALS._screenSurface.updateScreen(); + GLOBALS._screen.update(); g_system->delayMillis(10); } @@ -175,7 +175,7 @@ void SceneManager::changeScene(int newSceneNumber) { } // Blank out the screen - g_globals->_screenSurface.fillRect(g_globals->_screenSurface.getBounds(), 0); + g_globals->_screen.fillRect(g_globals->_screen.getBounds(), 0); // If there are any fading sounds, wait until fading is complete while (g_globals->_soundManager.isFading()) { @@ -463,7 +463,7 @@ void Scene::refreshBackground(int xAmount, int yAmount) { // Check if the section is already loaded if ((_enabledSections[xp * 16 + yp] == 0xffff) || ((xAmount == 0) && (yAmount == 0))) { // Chunk isn't loaded, so load it in - Graphics::Surface s = _backSurface.lockSurface(); + Graphics::ManagedSurface s = _backSurface.lockSurface(); GfxSurface::loadScreenSection(s, xp - xHalfOffset, yp - yHalfOffset, xp, yp); _backSurface.unlockSurface(); changedFlag = true; diff --git a/engines/tsage/screen.cpp b/engines/tsage/screen.cpp new file mode 100644 index 0000000000..f11c384797 --- /dev/null +++ b/engines/tsage/screen.cpp @@ -0,0 +1,46 @@ +/* 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 "common/scummsys.h" +#include "tsage/screen.h" + +namespace TsAGE { + +Screen::Screen(): GfxSurface(), Graphics::Screen() { + create(SCREEN_WIDTH, SCREEN_HEIGHT); +} + +void Screen::update() { + // When dialogs are active, the screen surface may be remapped to + // sub-sections of the screen. But for drawing we'll need to temporarily + // remove any such remappings and use the entirety of the screen + Rect clipBounds = getBounds(); + setBounds(Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); + + // Update the screen + Graphics::Screen::update(); + + // Reset the clipping + setBounds(clipBounds); +} + +} // End of namespace TsAGE diff --git a/engines/tsage/screen.h b/engines/tsage/screen.h new file mode 100644 index 0000000000..bf5057e4d6 --- /dev/null +++ b/engines/tsage/screen.h @@ -0,0 +1,59 @@ +/* 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 TSAGE_SCREEN_H +#define TSAGE_SCREEN_H + +#include "common/scummsys.h" +#include "common/array.h" +#include "graphics/screen.h" +#include "tsage/graphics.h" + +namespace TsAGE { + +#define SCREEN_WIDTH 320 +#define SCREEN_HEIGHT 200 +#define SCREEN_CENTER_X 160 +#define SCREEN_CENTER_Y 100 +#define UI_INTERFACE_Y 168 + +class Screen : virtual public Graphics::Screen, virtual public GfxSurface { +public: + /** + * Constructor + */ + Screen(); + + /** + * Destructor + */ + virtual ~Screen() {} + + /** + * Update the screen + */ + virtual void update(); +}; + +} // End of namespace TsAGE + +#endif /* MADS_SCREEN_H */ diff --git a/engines/tsage/tsage.h b/engines/tsage/tsage.h index 667a8daa59..1a29700a10 100644 --- a/engines/tsage/tsage.h +++ b/engines/tsage/tsage.h @@ -62,12 +62,6 @@ enum { struct tSageGameDescription; -#define SCREEN_WIDTH 320 -#define SCREEN_HEIGHT 200 -#define SCREEN_CENTER_X 160 -#define SCREEN_CENTER_Y 100 -#define UI_INTERFACE_Y 168 - class TSageEngine : public Engine { private: const tSageGameDescription *_gameDescription; diff --git a/engines/tsage/user_interface.cpp b/engines/tsage/user_interface.cpp index 3ee585d5ef..fffc0dc16c 100644 --- a/engines/tsage/user_interface.cpp +++ b/engines/tsage/user_interface.cpp @@ -253,7 +253,7 @@ void UICollection::show() { void UICollection::erase() { if (_clearScreen) { Rect tempRect(0, UI_INTERFACE_Y, SCREEN_WIDTH, SCREEN_HEIGHT); - GLOBALS._screenSurface.fillRect(tempRect, 0); + GLOBALS._screen.fillRect(tempRect, 0); GLOBALS._sceneManager._scene->_backSurface.fillRect(tempRect, 0); _clearScreen = false; } @@ -274,7 +274,7 @@ void UICollection::draw() { _objList[idx]->draw(); // Draw the resulting UI onto the screen - GLOBALS._screenSurface.copyFrom(GLOBALS._sceneManager._scene->_backSurface, + GLOBALS._screen.copyFrom(GLOBALS._sceneManager._scene->_backSurface, Rect(0, UI_INTERFACE_Y, SCREEN_WIDTH, SCREEN_HEIGHT), Rect(0, UI_INTERFACE_Y, SCREEN_WIDTH, SCREEN_HEIGHT)); @@ -293,12 +293,12 @@ void UICollection::r2rDrawFrame() { GfxSurface vertLineRight = visage.getFrame(3); GfxSurface horizLine = visage.getFrame(2); - GLOBALS._screenSurface.copyFrom(horizLine, 0, 0); - GLOBALS._screenSurface.copyFrom(vertLineLeft, 0, 3); - GLOBALS._screenSurface.copyFrom(vertLineRight, SCREEN_WIDTH - 4, 3); + GLOBALS._screen.copyFrom(horizLine, 0, 0); + GLOBALS._screen.copyFrom(vertLineLeft, 0, 3); + GLOBALS._screen.copyFrom(vertLineRight, SCREEN_WIDTH - 4, 3); // Restrict drawing area to exclude the borders at the edge of the screen - R2_GLOBALS._screenSurface._clipRect = Rect(4, 3, SCREEN_WIDTH - 4, + R2_GLOBALS._screen._clipRect = Rect(4, 3, SCREEN_WIDTH - 4, SCREEN_HEIGHT - 3); } -- cgit v1.2.3