From 80f7bc8e2a279624e81af9fb8f3acfbd26050702 Mon Sep 17 00:00:00 2001 From: Pawel Kolodziejski Date: Sat, 13 Aug 2005 20:14:46 +0000 Subject: [PATCH] added store/restore display buffer --- driver.h | 3 +-- driver_gl.cpp | 1 - driver_gl.h | 2 +- driver_tinygl.cpp | 11 +++++------ driver_tinygl.h | 3 ++- engine.cpp | 2 ++ lua.cpp | 34 ++-------------------------------- 7 files changed, 13 insertions(+), 43 deletions(-) diff --git a/driver.h b/driver.h index bb8e402e64a..521b6b4b194 100644 --- a/driver.h +++ b/driver.h @@ -84,7 +84,7 @@ public: virtual Bitmap *getScreenshot(int w, int h) = 0; virtual void storeDisplay() = 0; - virtual void flushStoredDisplay() = 0; + virtual void copyStoredToDisplay() = 0; virtual void enableDim(int x, int y, int w, int h) = 0; virtual void disableDim(int x, int y, int w, int h) = 0; @@ -104,7 +104,6 @@ protected: int _screenWidth, _screenHeight, _screenBPP; bool _isFullscreen; bool _dim; - byte *_storedDisplay; virtual void drawDim() = 0; }; diff --git a/driver_gl.cpp b/driver_gl.cpp index 74dc21a4d36..de3dcacee00 100644 --- a/driver_gl.cpp +++ b/driver_gl.cpp @@ -47,7 +47,6 @@ DriverGL::DriverGL(int screenW, int screenH, int screenBPP, bool fullscreen) { loadEmergFont(); _smushNumTex = 0; - _storedDisplay = NULL; } void DriverGL::toggleFullscreenMode() { diff --git a/driver_gl.h b/driver_gl.h index 27c6c430a86..fe0b7ecf859 100644 --- a/driver_gl.h +++ b/driver_gl.h @@ -67,7 +67,7 @@ public: Bitmap *getScreenshot(int w, int h); void storeDisplay() {} - void flushStoredDisplay() {} + void copyStoredToDisplay() {} void enableDim(int /*x*/, int /*y*/, int /*w*/, int /*h*/) { _dim = true; } void disableDim(int /*x*/, int /*y*/, int /*w*/, int /*h*/) { _dim = false; } diff --git a/driver_tinygl.cpp b/driver_tinygl.cpp index cd543963aaa..6e03034b09d 100644 --- a/driver_tinygl.cpp +++ b/driver_tinygl.cpp @@ -108,10 +108,12 @@ DriverTinyGL::DriverTinyGL(int screenW, int screenH, int screenBPP, bool fullscr _zb = ZB_open(screenW, screenH, ZB_MODE_5R6G5B, 0, NULL, NULL, _screen->pixels); tglInit(_zb); - _storedDisplay = NULL; + _storedDisplay = new byte[640 * 480 * 2]; + memset(_storedDisplay, 0, 640 * 480 * 2); } DriverTinyGL::~DriverTinyGL() { + delete []_storedDisplay; tglClose(); ZB_close(_zb); } @@ -490,14 +492,11 @@ Bitmap *DriverTinyGL::getScreenshot(int w, int h) { } void DriverTinyGL::storeDisplay() { - _storedDisplay = new byte[640 * 480 * 2]; - assert(_storedDisplay); memcpy(_storedDisplay, _zb->pbuf, 640 * 480 * 2); } -void DriverTinyGL::flushStoredDisplay() { - delete []_storedDisplay; - _storedDisplay = NULL; +void DriverTinyGL::copyStoredToDisplay() { + memcpy(_zb->pbuf, _storedDisplay, 640 * 480 * 2); } void DriverTinyGL::drawDim() { diff --git a/driver_tinygl.h b/driver_tinygl.h index c75a6134e91..bedf602ae6f 100644 --- a/driver_tinygl.h +++ b/driver_tinygl.h @@ -69,7 +69,7 @@ public: Bitmap *getScreenshot(int w, int h); void storeDisplay(); - void flushStoredDisplay(); + void copyStoredToDisplay(); void enableDim(int /*x*/, int /*y*/, int /*w*/, int /*h*/) { _dim = true; } void disableDim(int /*x*/, int /*y*/, int /*w*/, int /*h*/) { _dim = false; } @@ -94,6 +94,7 @@ private: byte *_smushBitmap; int _smushWidth; int _smushHeight; + byte *_storedDisplay; }; #endif diff --git a/engine.cpp b/engine.cpp index ef5e9cdd7ba..8a003d4b7af 100644 --- a/engine.cpp +++ b/engine.cpp @@ -270,6 +270,8 @@ void Engine::updateDisplayScene() { // The overlay objects should be drawn on top of everything else, // including 3D objects such as Manny and the message tube _currScene->drawBitmaps(ObjectState::OBJSTATE_OVERLAY); + + g_driver->storeDisplay(); } else if (_mode == ENGINE_MODE_DRAW) { if (_refreshDrawNeeded) { lua_beginblock(); diff --git a/lua.cpp b/lua.cpp index a1838a3acc5..4334bb42e15 100644 --- a/lua.cpp +++ b/lua.cpp @@ -2261,10 +2261,6 @@ void getTextObjectParams(TextObject *textObject, lua_Object table_obj) { } } -/* Clean the buffer of text objects and primitives - * this is known to be used when changing between menus - * and when loading some cutscenes - */ static void CleanBuffer() { DEBUG_FUNCTION(); g_engine->killPrimitiveObjects(); @@ -2272,36 +2268,9 @@ static void CleanBuffer() { // Cleanup references to deleted text objects for (Engine::ActorListType::const_iterator i = g_engine->actorsBegin(); i != g_engine->actorsEnd(); i++) (*i)->lineCleanup(); + //g_driver->copyStoredToDisplay(); } -/* Check to see if the menu item at a specific index has - * the "disabled" flag set - */ -bool itemDisabled(lua_Object itemTable, int menuItem) { - lua_Object table = getTableValue(itemTable, "items"); - lua_Object item = getIndexedTableValue(table, menuItem); - lua_Object itemdata = getTableValue(item, "props"); - lua_Object disabled = getTableValue(itemdata, "disabled"); - - if (!lua_isnil(disabled) && atoi(lua_getstring(disabled)) == 1) - return true; - else - return false; -} - -/* Find the text representing an item in the menu - */ -char *itemText(lua_Object itemTable, int menuItem) { - lua_Object table = getTableValue(itemTable, "items"); - lua_Object item = getIndexedTableValue(table, menuItem); - lua_Object itemtext = getTableValue(item, "text"); - - if (!lua_isnil(itemtext) && lua_isstring(itemtext)) - return lua_getstring(itemtext); - else - return NULL; -} - /* This function sends the SDL signal to * go ahead and exit the game */ @@ -2958,6 +2927,7 @@ static void RenderModeUser() { g_smush->pause(false); g_engine->refreshDrawMode(); g_engine->setMode(g_engine->getPreviousMode()); + CleanBuffer(); } else { error("RenderModeUser() Unknown type of param"); }