From 8d17584247e9c0820ac84e3bf290722b697a3aac Mon Sep 17 00:00:00 2001 From: athrxx Date: Thu, 14 Jan 2021 00:33:21 +0100 Subject: [PATCH] AGOS: (ELVIRA/PC98/Jp) - more dirty rect handling Make more use of dirty rect handling (applies to the PC-98 version only, the other versions don't need that). --- engines/agos/charset-fontdata.cpp | 3 ++- engines/agos/event.cpp | 3 ++- engines/agos/gfx.cpp | 36 ++++++++++++++++++++++--------- engines/agos/icons.cpp | 11 ++++++---- engines/agos/menus.cpp | 6 ++++-- engines/agos/verb.cpp | 3 ++- engines/agos/window.cpp | 8 +++++-- 7 files changed, 49 insertions(+), 21 deletions(-) diff --git a/engines/agos/charset-fontdata.cpp b/engines/agos/charset-fontdata.cpp index a10172647ce..664b6bb964c 100644 --- a/engines/agos/charset-fontdata.cpp +++ b/engines/agos/charset-fontdata.cpp @@ -3020,7 +3020,8 @@ void AGOSEngine::windowDrawChar(WindowBlock *window, uint x, uint y, byte chr) { dst += dstPitch; } while (--h); - updateBackendSurface(); + Common::Rect dirtyRect(x, y, x + 6, y + 8); + updateBackendSurface(&dirtyRect); _videoLockOut &= ~0x8000; } diff --git a/engines/agos/event.cpp b/engines/agos/event.cpp index 2708d0a6817..4a8f52a44d1 100644 --- a/engines/agos/event.cpp +++ b/engines/agos/event.cpp @@ -374,7 +374,8 @@ void AGOSEngine::drawStuff(const byte *src, uint xoffs) { dst += screen->pitch; } - updateBackendSurface(); + Common::Rect dirtyRect(xoffs, y, xoffs + 4, y + 6); + updateBackendSurface(&dirtyRect); } void AGOSEngine::playerDamageEvent(VgaTimerEntry * vte, uint dx) { diff --git a/engines/agos/gfx.cpp b/engines/agos/gfx.cpp index 07342277a50..a7e8b0c15ea 100644 --- a/engines/agos/gfx.cpp +++ b/engines/agos/gfx.cpp @@ -738,7 +738,7 @@ void AGOSEngine_Simon1::drawImage(VC10_state *state) { drawVertImage(state); } - updateBackendSurface(); + updateBackendSurface(); } void AGOSEngine::drawBackGroundImage(VC10_state *state) { @@ -859,7 +859,7 @@ void AGOSEngine::drawImage(VC10_state *state) { Graphics::Surface *screen = getBackendSurface(); - uint16 xoffs = 0, yoffs = 0; + uint16 xoffs = 0, yoffs = 0, xmax = 0, ymax = 0; if (getGameType() == GType_WW) { if (_windowNum == 4 || (_windowNum >= 10 && _windowNum <= 27)) { state->surf_addr = (byte *)_window4BackScn->getPixels(); @@ -868,8 +868,8 @@ void AGOSEngine::drawImage(VC10_state *state) { xoffs = ((vlut[0] - _videoWindows[16]) * 2 + state->x) * 8; yoffs = (vlut[1] - _videoWindows[17] + state->y); - uint xmax = (xoffs + state->draw_width * 2); - uint ymax = (yoffs + state->draw_height); + xmax = (xoffs + state->draw_width * 2); + ymax = (yoffs + state->draw_height); setMoveRect(xoffs, yoffs, xmax, ymax); _window4Flag = 1; @@ -879,6 +879,8 @@ void AGOSEngine::drawImage(VC10_state *state) { xoffs = (vlut[0] * 2 + state->x) * 8; yoffs = vlut[1] + state->y; + xmax = (xoffs + state->draw_width * 2); + ymax = (yoffs + state->draw_height); } } else if (getGameType() == GType_ELVIRA2) { if (_windowNum == 4 || _windowNum >= 10) { @@ -888,8 +890,8 @@ void AGOSEngine::drawImage(VC10_state *state) { xoffs = ((vlut[0] - _videoWindows[16]) * 2 + state->x) * 8; yoffs = (vlut[1] - _videoWindows[17] + state->y); - uint xmax = (xoffs + state->draw_width * 2); - uint ymax = (yoffs + state->draw_height); + xmax = (xoffs + state->draw_width * 2); + ymax = (yoffs + state->draw_height); setMoveRect(xoffs, yoffs, xmax, ymax); _window4Flag = 1; @@ -899,6 +901,8 @@ void AGOSEngine::drawImage(VC10_state *state) { xoffs = (vlut[0] * 2 + state->x) * 8; yoffs = vlut[1] + state->y; + xmax = (xoffs + state->draw_width * 2); + ymax = (yoffs + state->draw_height); } } else if (getGameType() == GType_ELVIRA1) { if (_windowNum == 6) { @@ -907,12 +911,16 @@ void AGOSEngine::drawImage(VC10_state *state) { xoffs = state->x * 8; yoffs = state->y; + xmax = xoffs + vlut[2] * 16; + ymax = yoffs + vlut[3]; } else if (_windowNum == 2 || _windowNum == 3) { state->surf_addr = (byte *)screen->getPixels(); state->surf_pitch = screen->pitch; xoffs = (vlut[0] * 2 + state->x) * 8; yoffs = vlut[1] + state->y; + xmax = xoffs + state->draw_width * 2; + ymax = yoffs + state->draw_height; } else { state->surf_addr = (byte *)_window4BackScn->getPixels(); state->surf_pitch = _videoWindows[18] * 16; @@ -920,8 +928,8 @@ void AGOSEngine::drawImage(VC10_state *state) { xoffs = ((vlut[0] - _videoWindows[16]) * 2 + state->x) * 8; yoffs = (vlut[1] - _videoWindows[17] + state->y); - uint xmax = (xoffs + state->draw_width * 2); - uint ymax = (yoffs + state->draw_height); + xmax = (xoffs + state->draw_width * 2); + ymax = (yoffs + state->draw_height); setMoveRect(xoffs, yoffs, xmax, ymax); _window4Flag = 1; @@ -951,7 +959,9 @@ void AGOSEngine::drawImage(VC10_state *state) { drawVertImage(state); } - updateBackendSurface(); + + Common::Rect dirtyRect(xoffs, yoffs, xmax, ymax); + updateBackendSurface(&dirtyRect); } void AGOSEngine::horizontalScroll(VC10_state *state) { @@ -1527,9 +1537,15 @@ void AGOSEngine::setWindowImage(uint16 mode, uint16 vgaSpriteId, bool specialCas dst[w] += 0x10; dst += screen->pitch; } + + if (getPlatform() == Common::kPlatformPC98) { + Common::Rect dirtyRect(0, 133, _screenWidth, _screenHeight); + updateBackendSurface(&dirtyRect); + } } - updateBackendSurface(); + Common::Rect dirtyRect(xoffs, yoffs, xoffs + width, yoffs + _boxStarHeight); + updateBackendSurface(&dirtyRect); } _videoLockOut &= ~0x20; diff --git a/engines/agos/icons.cpp b/engines/agos/icons.cpp index 3bbec55f3e8..3aa25d4249a 100644 --- a/engines/agos/icons.cpp +++ b/engines/agos/icons.cpp @@ -315,8 +315,9 @@ void AGOSEngine_Elvira1::drawIcon(WindowBlock *window, uint icon, uint x, uint y Graphics::Surface *screen = getBackendSurface(); dst = (byte *)screen->getPixels(); - dst += (x + window->x) * 8; - dst += (y * 8 + window->y) * screen->pitch; + x = (x + window->x) * 8; + y = (y * 8 + window->y); + dst += y * screen->pitch + x; if (getFeatures() & GF_PLANAR) { src = _iconFilePtr; @@ -328,7 +329,8 @@ void AGOSEngine_Elvira1::drawIcon(WindowBlock *window, uint icon, uint x, uint y decompressIconPlanar(dst, src, 24, 12, 16, screen->pitch, false); } - updateBackendSurface(); + Common::Rect dirtyRect(x, y, x + 24, y + 12); + updateBackendSurface(&dirtyRect); _videoLockOut &= ~0x8000; } @@ -964,7 +966,8 @@ void AGOSEngine::drawArrow(uint16 x, uint16 y, int8 dir) { dst+= screen->pitch; } - updateBackendSurface(); + Common::Rect dirtyRect(x * 8, y, x * 8 + 16, y + 19); + updateBackendSurface(&dirtyRect); } void AGOSEngine_Simon1::removeArrows(WindowBlock *window, uint num) { diff --git a/engines/agos/menus.cpp b/engines/agos/menus.cpp index 7de21be1467..7617c11681b 100644 --- a/engines/agos/menus.cpp +++ b/engines/agos/menus.cpp @@ -179,7 +179,8 @@ void AGOSEngine::unlightMenuStrip() { for (i = 120; i != 130; i++) disableBox(i); - updateBackendSurface(); + Common::Rect dirtyRect(272, 8, 320, 90); + updateBackendSurface(&dirtyRect); mouseOn(); } @@ -204,7 +205,8 @@ void AGOSEngine::lightMenuBox(uint hitarea) { src += screen->pitch; } while (--h); - updateBackendSurface(); + Common::Rect dirtyRect(ha->x, ha->y, ha->x + w, ha->y + ha->height); + updateBackendSurface(&dirtyRect); mouseOn(); } diff --git a/engines/agos/verb.cpp b/engines/agos/verb.cpp index 7f1ff7592cc..75c40d9899b 100644 --- a/engines/agos/verb.cpp +++ b/engines/agos/verb.cpp @@ -1041,7 +1041,8 @@ void AGOSEngine::invertBox(HitArea *ha, byte a, byte b, byte c, byte d) { src += screen->pitch; } while (--h); - updateBackendSurface(); + Common::Rect dirtyRect(ha->x, ha->y, ha->x + w, ha->y + ha->height); + updateBackendSurface(&dirtyRect); _videoLockOut &= ~0x8000; } diff --git a/engines/agos/window.cpp b/engines/agos/window.cpp index 8be23ef249a..70775e99420 100644 --- a/engines/agos/window.cpp +++ b/engines/agos/window.cpp @@ -178,13 +178,15 @@ void AGOSEngine::colorBlock(WindowBlock *window, uint16 x, uint16 y, uint16 w, u uint8 color = window->fillColor; if (getGameType() == GType_ELVIRA2 || getGameType() == GType_WW) color += dst[0] & 0xF0; + uint16 h2 = h; do { memset(dst, color, w); dst += screen->pitch; } while (--h); - updateBackendSurface(); + Common::Rect dirtyRect(x, y, x + w, y + h2); + updateBackendSurface(&dirtyRect); _videoLockOut &= ~0x8000; } @@ -242,6 +244,7 @@ void AGOSEngine::restoreBlock(uint16 x, uint16 y, uint16 w, uint16 h) { src += y * _backGroundBuf->pitch; uint8 paletteMod = 0; + uint16 h2 = 2; if (getGameType() == GType_ELVIRA1 && !(getFeatures() & GF_DEMO) && y >= 133) paletteMod = 16; @@ -253,7 +256,8 @@ void AGOSEngine::restoreBlock(uint16 x, uint16 y, uint16 w, uint16 h) { src += _backGroundBuf->pitch; } - updateBackendSurface(); + Common::Rect dirtyRect(x, y, x + w, y + h2); + updateBackendSurface(&dirtyRect); } void AGOSEngine::setTextColor(uint color) {