From cf4cba9c20378bf707da2053ee6cf06857165f0e Mon Sep 17 00:00:00 2001 From: Martin Gerhardy Date: Sat, 2 Jan 2021 13:44:11 +0100 Subject: [PATCH] TWINE: plasma effect for higher resolutions --- engines/twine/debugger/debug.cpp | 2 +- engines/twine/menu/menu.cpp | 16 +++++++++------- engines/twine/menu/menu.h | 5 ++--- engines/twine/menu/menuoptions.cpp | 8 ++++---- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/engines/twine/debugger/debug.cpp b/engines/twine/debugger/debug.cpp index 48dc983144a..ddc47a274fb 100644 --- a/engines/twine/debugger/debug.cpp +++ b/engines/twine/debugger/debug.cpp @@ -401,7 +401,7 @@ int32 Debug::debugProcessButton(int32 x, int32 y) { } void Debug::debugPlasmaWindow(const char *text, int32 color) { - _engine->_menu->processPlasmaEffect(0, 5, color); + _engine->_menu->processPlasmaEffect(Common::Rect(0, 0, PLASMA_WIDTH, PLASMA_HEIGHT), color); if (!(_engine->getRandomNumber() % 5)) { _engine->_menu->plasmaEffectPtr[_engine->getRandomNumber() % PLASMA_WIDTH * 10 + 6400] = 255; } diff --git a/engines/twine/menu/menu.cpp b/engines/twine/menu/menu.cpp index ea70f1c276c..18e5566d362 100644 --- a/engines/twine/menu/menu.cpp +++ b/engines/twine/menu/menu.cpp @@ -209,16 +209,16 @@ void Menu::plasmaEffectRenderFrame() { memcpy(plasmaEffectPtr, src, PLASMA_HEIGHT * PLASMA_WIDTH); } -void Menu::processPlasmaEffect(int32 left, int32 top, int32 color) { +void Menu::processPlasmaEffect(const Common::Rect &rect, int32 color) { const int32 max_value = color + 15; plasmaEffectRenderFrame(); const uint8 *in = plasmaEffectPtr + 5 * PLASMA_WIDTH; - uint8 *out = (uint8 *)_engine->frontVideoBuffer.getBasePtr(left, top); + uint8 *out = (uint8 *)_engine->imageBuffer.getBasePtr(0, 0); for (int32 y = 0; y < PLASMA_HEIGHT / 2; y++) { - int32 yOffset = y * SCREEN_WIDTH; + int32 yOffset = y * _engine->imageBuffer.w; const uint8 *colPtr = &in[y * PLASMA_WIDTH]; for (int32 x = 0; x < PLASMA_WIDTH; x++) { const uint8 c = MIN(*colPtr / 2 + color, max_value); @@ -226,12 +226,14 @@ void Menu::processPlasmaEffect(int32 left, int32 top, int32 color) { const int32 target = 2 * yOffset; out[target + 0] = c; out[target + 1] = c; - out[target + SCREEN_WIDTH + 0] = c; - out[target + SCREEN_WIDTH + 1] = c; + out[target + _engine->imageBuffer.w + 0] = c; + out[target + _engine->imageBuffer.w + 1] = c; ++colPtr; ++yOffset; } } + const Common::Rect prect(0, 0, PLASMA_WIDTH, PLASMA_HEIGHT); + _engine->frontVideoBuffer.transBlitFrom(_engine->imageBuffer, prect, rect); } void Menu::drawBox(const Common::Rect &rect) { @@ -277,13 +279,13 @@ void Menu::drawButtonGfx(const MenuSettings *menuSettings, const Common::Rect &r } } - processPlasmaEffect(rect.left, rect.top, 80); + processPlasmaEffect(rect, 80); if (!(_engine->getRandomNumber() % 5)) { plasmaEffectPtr[_engine->getRandomNumber() % 140 * 10 + 1900] = 255; } _engine->_interface->drawSplittedBox(Common::Rect(newWidth, rect.top, rect.right, rect.bottom), 68); } else { - processPlasmaEffect(rect.left, rect.top, 64); + processPlasmaEffect(rect, 64); if (!(_engine->getRandomNumber() % 5)) { plasmaEffectPtr[_engine->getRandomNumber() % 320 * 10 + 6400] = 255; } diff --git a/engines/twine/menu/menu.h b/engines/twine/menu/menu.h index 699122a43db..b6bdb35cfa0 100644 --- a/engines/twine/menu/menu.h +++ b/engines/twine/menu/menu.h @@ -30,7 +30,7 @@ namespace TwinE { #define MAX_BUTTONS 10 -#define PLASMA_WIDTH (SCREEN_WIDTH / 2) +#define PLASMA_WIDTH 320 #define PLASMA_HEIGHT 50 #define kQuitEngine 9998 @@ -203,10 +203,9 @@ public: /** * Process the plasma effect - * @param top top height where the effect will be draw in the front buffer * @param color plasma effect start color */ - void processPlasmaEffect(int32 left, int32 top, int32 color); + void processPlasmaEffect(const Common::Rect &rect, int32 color); /** * Draw the entire button box diff --git a/engines/twine/menu/menuoptions.cpp b/engines/twine/menu/menuoptions.cpp index 7d544a9425c..00f3c288ccc 100644 --- a/engines/twine/menu/menuoptions.cpp +++ b/engines/twine/menu/menuoptions.cpp @@ -212,13 +212,13 @@ void MenuOptions::drawSelectableCharacters() { void MenuOptions::drawPlayerName(int32 centerx, int32 top, int32 type) { const int32 left = 10; - if (type == 1) { - _engine->_menu->processPlasmaEffect(left, top, 32); - } - const int right = SCREEN_WIDTH - left; const int bottom = top + PLASMA_HEIGHT; const Common::Rect rect(left, top, right, bottom); + if (type == 1) { + _engine->_menu->processPlasmaEffect(rect, 32); + } + Common::Rect rectBox(rect); rectBox.grow(-1); _engine->_menu->drawBox(rect);