From 317bd9ebd088ed1e0329d14d9571015e31cc8de6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 24 Feb 2013 22:03:38 -0500 Subject: HOPKINS: Beginnings of implementing dirty rect support --- engines/hopkins/graphics.cpp | 96 ++++++++++++++++++++++++++------------------ 1 file changed, 57 insertions(+), 39 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index b299082394..a339f9799b 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -47,7 +47,11 @@ GraphicsManager::GraphicsManager() { _scrollPosX = 0; _largeScreenFl = false; _oldScrollPosX = 0; - NBBLOC = 0; + _dirtyRectCount = 0; + _vesaScreen = NULL; + _vesaBuffer = NULL; + _screenBuffer = NULL; + _isPhysicalPtr = false; _lineNbr2 = 0; Agr_x = Agr_y = 0; @@ -73,14 +77,15 @@ GraphicsManager::GraphicsManager() { Common::fill(&_palette[0], &_palette[PALETTE_EXT_BLOCK_SIZE], 0); Common::fill(&_oldPalette[0], &_oldPalette[PALETTE_EXT_BLOCK_SIZE], 0); - for (int i = 0; i < 250; ++i) - Common::fill((byte *)&BLOC[i], (byte *)&BLOC[i] + sizeof(BlocItem), 0); + for (int i = 0; i < DIRTY_RECTS_SIZE; ++i) + Common::fill((byte *)&_dirtyRects[i], (byte *)&_dirtyRects[i] + sizeof(BlocItem), 0); } GraphicsManager::~GraphicsManager() { _vm->_globals.freeMemory(_vesaScreen); _vm->_globals.freeMemory(_vesaBuffer); + _vm->_globals.freeMemory(_screenBuffer); } void GraphicsManager::setParent(HopkinsEngine *vm) { @@ -107,14 +112,13 @@ void GraphicsManager::setGraphicalMode(int width, int height) { // Init surfaces _vesaScreen = _vm->_globals.allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); _vesaBuffer = _vm->_globals.allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); + _screenBuffer = _vm->_globals.allocMemory(SCREEN_WIDTH * 2 * SCREEN_HEIGHT); _videoPtr = NULL; _screenWidth = width; _screenHeight = height; - // Clear the screen pitch. This will be set on the first lockScreen call - WinScan = 0; - + WinScan = width * 2; PAL_PIXELS = SD_PIXELS; _lineNbr = width; @@ -127,12 +131,19 @@ void GraphicsManager::setGraphicalMode(int width, int height) { /** * (try to) Lock Screen */ -void GraphicsManager::lockScreen() { +void GraphicsManager::lockScreen(bool shouldUsePhysicalScreen) { if (!_skipVideoLockFl) { if (_lockCounter++ == 0) { - _videoPtr = g_system->lockScreen(); - if (WinScan == 0) - WinScan = _videoPtr->pitch; + if (shouldUsePhysicalScreen) { + Graphics::Surface *s = g_system->lockScreen(); + _videoPtr = (byte *)s->pixels; + WinScan = s->pitch; + } else { + _videoPtr = _screenBuffer; + WinScan = _width * 2; + } + + _isPhysicalPtr = shouldUsePhysicalScreen; } } } @@ -143,7 +154,9 @@ void GraphicsManager::lockScreen() { void GraphicsManager::unlockScreen() { assert(_videoPtr); if (--_lockCounter == 0) { - g_system->unlockScreen(); + if (_isPhysicalPtr) + g_system->unlockScreen(); + _videoPtr = NULL; } } @@ -153,7 +166,7 @@ void GraphicsManager::unlockScreen() { */ void GraphicsManager::clearScreen() { assert(_videoPtr); - _videoPtr->fillRect(Common::Rect(0, 0, _screenWidth, _screenHeight), 0); + Common::fill(_videoPtr, _videoPtr + WinScan * _screenHeight, 0); } /** @@ -395,14 +408,10 @@ void GraphicsManager::loadPCX320(byte *surface, const Common::String &file, byte } // Clear Palette -// CHECKME: Some versions of the game don't include it, some contains nothing more than -// than a loop doing nothing, some others just map the last value. While debugging, it -// seems that this function is called once the palette is already cleared, so it would be useless -// This code could most likely be removed. void GraphicsManager::clearPalette() { - uint16 col0 = mapRGB(0, 0, 0); - for (int i = 0; i < 512; i += 2) - WRITE_LE_UINT16(&SD_PIXELS[i], col0); + // As weird as it sounds, this is what the original Linux executable does, + // and not a full array clear. + SD_PIXELS[0] = 0; } void GraphicsManager::SCANLINE(int pitch) { @@ -417,7 +426,7 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, assert(_videoPtr); const byte *srcP = xs + _lineNbr2 * ys + surface; - byte *destP = (byte *)_videoPtr->pixels + destX * 2 + WinScan * destY; + byte *destP = (byte *)_videoPtr + destX * 2 + WinScan * destY; for (int yp = 0; yp < height; ++yp) { // Copy over the line, using the source pixels as lookups into the pixels palette @@ -436,6 +445,7 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, } unlockScreen(); + addVesaSegment(xs, ys, xs + width, ys + height); } // TODO: See if PAL_PIXELS can be converted to a uint16 array @@ -448,7 +458,7 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width assert(_videoPtr); const byte *srcP = xs + _lineNbr2 * ys + surface; - byte *destP = (byte *)_videoPtr->pixels + destX + destX + WinScan * destY; + byte *destP = (byte *)_videoPtr + destX + destX + WinScan * destY; int yNext = height; Agr_x = 0; Agr_y = 0; @@ -494,6 +504,8 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width srcP = _lineNbr2 + srcCopyP; yNext = yCtr - 1; } while (yCtr != 1); + + addVesaSegment(xs, ys, xs + width, ys + width); } void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { @@ -506,7 +518,7 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, assert(_videoPtr); const byte *srcP = surface + xp + 320 * yp; - byte *destP = (byte *)_videoPtr->pixels + 30 * WinScan + destX + destX + destX + destX + WinScan * 2 * destY; + byte *destP = (byte *)_videoPtr + 30 * WinScan + destX + destX + destX + destX + WinScan * 2 * destY; int yCount = height; int xCount = width; @@ -531,6 +543,8 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, srcP = loopSrcP + 320; yCount = yCtr - 1; } while (yCtr != 1); + + addVesaSegment(xp, yp, xp + width, yp + width); } /** @@ -816,7 +830,7 @@ void GraphicsManager::copyVideoVbe16(const byte *srcData) { if (srcByte == 211) { int pixelCount = srcP[1]; int pixelIndex = srcP[2]; - byte *destP = (byte *)_videoPtr->pixels + destOffset * 2; + byte *destP = (byte *)_videoPtr + destOffset * 2; destOffset += pixelCount; while (pixelCount--) { @@ -829,7 +843,7 @@ void GraphicsManager::copyVideoVbe16(const byte *srcData) { } else { int pixelCount = srcByte - 211; int pixelIndex = srcP[1]; - byte *destP = (byte *)_videoPtr->pixels + destOffset * 2; + byte *destP = (byte *)_videoPtr + destOffset * 2; destOffset += pixelCount; while (pixelCount--) { @@ -841,7 +855,7 @@ void GraphicsManager::copyVideoVbe16(const byte *srcData) { srcP += 2; } } else { - byte *destP = (byte *)_videoPtr->pixels + destOffset * 2; + byte *destP = (byte *)_videoPtr + destOffset * 2; destP[0] = PAL_PIXELS[2 * srcByte]; destP[1] = PAL_PIXELS[(2 * srcByte) + 1]; ++srcP; @@ -875,7 +889,7 @@ void GraphicsManager::copyVideoVbe16a(const byte *srcData) { } } - WRITE_LE_UINT16((byte *)_videoPtr->pixels + destOffset * 2, READ_LE_UINT16(PAL_PIXELS + 2 * srcByte)); + WRITE_LE_UINT16((byte *)_videoPtr + destOffset * 2, READ_LE_UINT16(PAL_PIXELS + 2 * srcByte)); ++srcP; ++destOffset; } @@ -1080,10 +1094,10 @@ void GraphicsManager::displayAllBob() { } void GraphicsManager::resetVesaSegment() { - for (int idx = 0; idx <= NBBLOC; idx++) - BLOC[idx]._activeFl = false; + for (int idx = 0; idx <= _dirtyRectCount; idx++) + _dirtyRects[idx]._activeFl = false; - NBBLOC = 0; + _dirtyRectCount = 0; } // Add VESA Segment @@ -1099,15 +1113,15 @@ void GraphicsManager::addVesaSegment(int x1, int y1, int x2, int y2) { if (y1 < _minY) y1 = _minY; - for (int blocIndex = 0; blocIndex <= NBBLOC; blocIndex++) { - BlocItem &bloc = BLOC[blocIndex]; + for (int blocIndex = 0; blocIndex <= _dirtyRectCount; blocIndex++) { + BlocItem &bloc = _dirtyRects[blocIndex]; if (bloc._activeFl && tempX >= bloc._x1 && x2 <= bloc._x2 && y1 >= bloc._y1 && y2 <= bloc._y2) addFlag = false; }; if (addFlag) { - assert(NBBLOC < 250); - BlocItem &bloc = BLOC[++NBBLOC]; + assert(_dirtyRectCount < DIRTY_RECTS_SIZE); + BlocItem &bloc = _dirtyRects[++_dirtyRectCount]; bloc._activeFl = true; bloc._x1 = tempX; @@ -1119,13 +1133,13 @@ void GraphicsManager::addVesaSegment(int x1, int y1, int x2, int y2) { // Display VESA Segment void GraphicsManager::displayVesaSegment() { - if (NBBLOC == 0) + if (_dirtyRectCount == 0) return; lockScreen(); - for (int idx = 1; idx <= NBBLOC; ++idx) { - BlocItem &bloc = BLOC[idx]; + for (int idx = 1; idx <= _dirtyRectCount; ++idx) { + BlocItem &bloc = _dirtyRects[idx]; Common::Rect &dstRect = dstrect[idx - 1]; if (!bloc._activeFl) continue; @@ -1154,11 +1168,15 @@ void GraphicsManager::displayVesaSegment() { unlockScreen(); } - BLOC[idx]._activeFl = false; + byte *srcP = _videoPtr + WinScan * dstRect.top + (dstRect.left * 2); + g_system->copyRectToScreen(srcP, WinScan, dstRect.left, dstRect.top, + dstRect.width(), dstRect.height()); + + _dirtyRects[idx]._activeFl = false; } - NBBLOC = 0; unlockScreen(); + _dirtyRectCount = 0; } void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, int idx, bool addSegment) { @@ -1184,7 +1202,7 @@ void GraphicsManager::copy16bFromSurfaceScaleX2(const byte *surface) { assert(_videoPtr); const byte *curSurface = surface; - byte *destPtr = 30 * WinScan + (byte *)_videoPtr->pixels; + byte *destPtr = 30 * WinScan + (byte *)_videoPtr; for (int y = 200; y; y--) { byte *oldDestPtr = destPtr; for (int x = 320; x; x--) { -- cgit v1.2.3 From 54924de6cbd07e8b8cb2eb91067a0d31d08b55c8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 25 Feb 2013 22:00:36 -0500 Subject: HOPKINS: Home-screen now displaying correctly with dirty rects --- engines/hopkins/graphics.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index a339f9799b..31332324fe 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -118,7 +118,7 @@ void GraphicsManager::setGraphicalMode(int width, int height) { _screenWidth = width; _screenHeight = height; - WinScan = width * 2; + WinScan = SCREEN_WIDTH * 2; PAL_PIXELS = SD_PIXELS; _lineNbr = width; @@ -140,7 +140,7 @@ void GraphicsManager::lockScreen(bool shouldUsePhysicalScreen) { WinScan = s->pitch; } else { _videoPtr = _screenBuffer; - WinScan = _width * 2; + WinScan = SCREEN_WIDTH * 2; } _isPhysicalPtr = shouldUsePhysicalScreen; @@ -203,6 +203,7 @@ void GraphicsManager::loadVgaImage(const Common::String &file) { */ void GraphicsManager::loadScreen(const Common::String &file) { Common::File f; + assert(!_videoPtr || !_isPhysicalPtr); bool flag = true; if (_vm->_fileManager.searchCat(file, 6) == g_PTRNUL) { @@ -242,7 +243,7 @@ void GraphicsManager::loadScreen(const Common::String &file) { } } - memcpy(_vesaBuffer, _vesaScreen, SCREEN_WIDTH * 2 * SCREEN_HEIGHT); + memcpy(_vesaBuffer, _vesaScreen, SCREEN_WIDTH * 2 * SCREEN_HEIGHT); } void GraphicsManager::initColorTable(int minIndex, int maxIndex, byte *palette) { @@ -445,7 +446,7 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, } unlockScreen(); - addVesaSegment(xs, ys, xs + width, ys + height); + addDirtyRect(xs, ys, xs + width, ys + height); } // TODO: See if PAL_PIXELS can be converted to a uint16 array @@ -505,7 +506,7 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width yNext = yCtr - 1; } while (yCtr != 1); - addVesaSegment(xs, ys, xs + width, ys + width); + addDirtyRect(xs, ys, xs + width, ys + width); } void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { @@ -544,7 +545,7 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, yCount = yCtr - 1; } while (yCtr != 1); - addVesaSegment(xp, yp, xp + width, yp + width); + addDirtyRect(xp, yp, xp + width, yp + width); } /** @@ -1101,7 +1102,7 @@ void GraphicsManager::resetVesaSegment() { } // Add VESA Segment -void GraphicsManager::addVesaSegment(int x1, int y1, int x2, int y2) { +void GraphicsManager::addDirtyRect(int x1, int y1, int x2, int y2) { int tempX = x1; bool addFlag = true; if (x2 > _maxX) @@ -1190,7 +1191,7 @@ void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, i Sprite_Vesa(_vesaScreen, objectData, xp + 300, yp + 300, idx); } if (addSegment) - addVesaSegment(xp, yp, xp + width, yp + height); + addDirtyRect(xp, yp, xp + width, yp + height); } /** @@ -1609,7 +1610,7 @@ void GraphicsManager::fastDisplay(const byte *spriteData, int xp, int yp, int sp Sprite_Vesa(_vesaScreen, spriteData, xp + 300, yp + 300, spriteIndex); } if (addSegment) - addVesaSegment(xp, yp, xp + width, yp + height); + addDirtyRect(xp, yp, xp + width, yp + height); } void GraphicsManager::copySurface(const byte *surface, int x1, int y1, int width, int height, byte *destSurface, int destX, int destY) { @@ -1635,7 +1636,7 @@ void GraphicsManager::copySurface(const byte *surface, int x1, int y1, int width if (croppedWidth > 0 && croppedHeight > 0) { int height2 = croppedHeight; Copy_Mem(surface, left, top, croppedWidth, croppedHeight, destSurface, destX, destY); - addVesaSegment(left, top, left + croppedWidth, top + height2); + addDirtyRect(left, top, left + croppedWidth, top + height2); } } -- cgit v1.2.3 From c3bab0aecbb00f55493a0816c217d33dc9359793 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 26 Feb 2013 07:57:30 -0500 Subject: HOPKINS: Cleaned up the addDirtyRect method --- engines/hopkins/graphics.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 31332324fe..ea65ad7432 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1103,29 +1103,25 @@ void GraphicsManager::resetVesaSegment() { // Add VESA Segment void GraphicsManager::addDirtyRect(int x1, int y1, int x2, int y2) { - int tempX = x1; bool addFlag = true; - if (x2 > _maxX) - x2 = _maxX; - if (y2 > _maxY) - y2 = _maxY; - if (x1 < _minX) - tempX = _minX; - if (y1 < _minY) - y1 = _minY; + + x1 = CLIP(x1, _minX, _maxX); + y1 = CLIP(y1, _minY, _maxY); + x2 = CLIP(x2, _minX, _maxX); + y2 = CLIP(y2, _minY, _maxY); for (int blocIndex = 0; blocIndex <= _dirtyRectCount; blocIndex++) { BlocItem &bloc = _dirtyRects[blocIndex]; - if (bloc._activeFl && tempX >= bloc._x1 && x2 <= bloc._x2 && y1 >= bloc._y1 && y2 <= bloc._y2) + if (bloc._activeFl && x1 >= bloc._x1 && x2 <= bloc._x2 && y1 >= bloc._y1 && y2 <= bloc._y2) addFlag = false; }; - if (addFlag) { + if (addFlag && (x2 > x1) && (y2 > y1)) { assert(_dirtyRectCount < DIRTY_RECTS_SIZE); BlocItem &bloc = _dirtyRects[++_dirtyRectCount]; bloc._activeFl = true; - bloc._x1 = tempX; + bloc._x1 = x1; bloc._x2 = x2; bloc._y1 = y1; bloc._y2 = y2; -- cgit v1.2.3 From d738802bc1d1441fee8bce3881cd5233044305d6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Mar 2013 17:30:42 -0500 Subject: HOPKINS: Converted dirty rects to use Common::Array --- engines/hopkins/graphics.cpp | 83 ++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 50 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index ea65ad7432..c998a3b011 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -47,7 +47,6 @@ GraphicsManager::GraphicsManager() { _scrollPosX = 0; _largeScreenFl = false; _oldScrollPosX = 0; - _dirtyRectCount = 0; _vesaScreen = NULL; _vesaBuffer = NULL; _screenBuffer = NULL; @@ -76,10 +75,6 @@ GraphicsManager::GraphicsManager() { Common::fill(&_colorTable[0], &_colorTable[PALETTE_EXT_BLOCK_SIZE], 0); Common::fill(&_palette[0], &_palette[PALETTE_EXT_BLOCK_SIZE], 0); Common::fill(&_oldPalette[0], &_oldPalette[PALETTE_EXT_BLOCK_SIZE], 0); - - for (int i = 0; i < DIRTY_RECTS_SIZE; ++i) - Common::fill((byte *)&_dirtyRects[i], (byte *)&_dirtyRects[i] + sizeof(BlocItem), 0); - } GraphicsManager::~GraphicsManager() { @@ -1095,72 +1090,62 @@ void GraphicsManager::displayAllBob() { } void GraphicsManager::resetVesaSegment() { - for (int idx = 0; idx <= _dirtyRectCount; idx++) - _dirtyRects[idx]._activeFl = false; - - _dirtyRectCount = 0; + _dirtyRects.clear(); } // Add VESA Segment void GraphicsManager::addDirtyRect(int x1, int y1, int x2, int y2) { - bool addFlag = true; - x1 = CLIP(x1, _minX, _maxX); y1 = CLIP(y1, _minY, _maxY); x2 = CLIP(x2, _minX, _maxX); y2 = CLIP(y2, _minY, _maxY); - for (int blocIndex = 0; blocIndex <= _dirtyRectCount; blocIndex++) { - BlocItem &bloc = _dirtyRects[blocIndex]; - if (bloc._activeFl && x1 >= bloc._x1 && x2 <= bloc._x2 && y1 >= bloc._y1 && y2 <= bloc._y2) - addFlag = false; - }; - - if (addFlag && (x2 > x1) && (y2 > y1)) { - assert(_dirtyRectCount < DIRTY_RECTS_SIZE); - BlocItem &bloc = _dirtyRects[++_dirtyRectCount]; - - bloc._activeFl = true; - bloc._x1 = x1; - bloc._x2 = x2; - bloc._y1 = y1; - bloc._y2 = y2; + Common::Rect newRect(x1, y1, x2, y2); + if (!newRect.isValidRect()) + return; + + // Don't bother adding the rect if it's contained within another existing one + for (uint rectIndex = 0; rectIndex < _dirtyRects.size(); ++rectIndex) { + const Common::Rect &r = _dirtyRects[rectIndex]; + if (r.contains(newRect)) + return; } + + assert(_dirtyRects.size() < DIRTY_RECTS_SIZE); + _dirtyRects.push_back(newRect); } // Display VESA Segment void GraphicsManager::displayVesaSegment() { - if (_dirtyRectCount == 0) + if (_dirtyRects.size() == 0) return; lockScreen(); - for (int idx = 1; idx <= _dirtyRectCount; ++idx) { - BlocItem &bloc = _dirtyRects[idx]; - Common::Rect &dstRect = dstrect[idx - 1]; - if (!bloc._activeFl) - continue; + for (uint idx = 0; idx < _dirtyRects.size(); ++idx) { + Common::Rect &r = _dirtyRects[idx]; + Common::Rect &dstRect = dstrect[idx]; if (_vm->_eventsManager._breakoutFl) { - Copy_Vga16(_vesaBuffer, bloc._x1, bloc._y1, bloc._x2 - bloc._x1, bloc._y2 - bloc._y1, bloc._x1, bloc._y1); - dstRect.left = bloc._x1 * 2; - dstRect.top = bloc._y1 * 2 + 30; - dstRect.setWidth((bloc._x2 - bloc._x1) * 2); - dstRect.setHeight((bloc._y2 - bloc._y1) * 2); - } else if (bloc._x2 > _vm->_eventsManager._startPos.x && bloc._x1 < _vm->_eventsManager._startPos.x + SCREEN_WIDTH) { - if (bloc._x1 < _vm->_eventsManager._startPos.x) - bloc._x1 = _vm->_eventsManager._startPos.x; - if (bloc._x2 > _vm->_eventsManager._startPos.x + SCREEN_WIDTH) - bloc._x2 = _vm->_eventsManager._startPos.x + SCREEN_WIDTH; + Copy_Vga16(_vesaBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left, r.top); + dstRect.left = r.left * 2; + dstRect.top = r.top * 2 + 30; + dstRect.setWidth((r.right - r.left) * 2); + dstRect.setHeight((r.bottom - r.top) * 2); + } else if (r.right > _vm->_eventsManager._startPos.x && r.left < _vm->_eventsManager._startPos.x + SCREEN_WIDTH) { + if (r.left < _vm->_eventsManager._startPos.x) + r.left = _vm->_eventsManager._startPos.x; + if (r.right > _vm->_eventsManager._startPos.x + SCREEN_WIDTH) + r.right = _vm->_eventsManager._startPos.x + SCREEN_WIDTH; // WORKAROUND: Original didn't lock the screen for access lockScreen(); - m_scroll16(_vesaBuffer, bloc._x1, bloc._y1, bloc._x2 - bloc._x1, bloc._y2 - bloc._y1, bloc._x1 - _vm->_eventsManager._startPos.x, bloc._y1); + m_scroll16(_vesaBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left - _vm->_eventsManager._startPos.x, r.top); - dstRect.left = bloc._x1 - _vm->_eventsManager._startPos.x; - dstRect.top = bloc._y1; - dstRect.setWidth(bloc._x2 - bloc._x1); - dstRect.setHeight(bloc._y2 - bloc._y1); + dstRect.left = r.left - _vm->_eventsManager._startPos.x; + dstRect.top = r.top; + dstRect.setWidth(r.right - r.left); + dstRect.setHeight(r.bottom - r.top); unlockScreen(); } @@ -1168,12 +1153,10 @@ void GraphicsManager::displayVesaSegment() { byte *srcP = _videoPtr + WinScan * dstRect.top + (dstRect.left * 2); g_system->copyRectToScreen(srcP, WinScan, dstRect.left, dstRect.top, dstRect.width(), dstRect.height()); - - _dirtyRects[idx]._activeFl = false; } unlockScreen(); - _dirtyRectCount = 0; + resetVesaSegment(); } void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, int idx, bool addSegment) { -- cgit v1.2.3 From 7c862d586ede81d759eafae831f8fd54684d92bd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Mar 2013 18:56:14 -0500 Subject: HOPKINS: Preparatory work for a refresh rect list --- engines/hopkins/graphics.cpp | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index c998a3b011..4fe9c4ef39 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -612,7 +612,7 @@ void GraphicsManager::fadeOut(const byte *palette, int step, const byte *surface setPaletteVGA256(palData); m_scroll16(surface, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); - return DD_VBL(); + DD_VBL(); } /** @@ -735,7 +735,10 @@ uint16 GraphicsManager::mapRGB(byte r, byte g, byte b) { } void GraphicsManager::DD_VBL() { - // TODO: Is this okay here? + // Display any aras of the screen that need refreshing + displayRefreshRects(); + + // Update the screen g_system->updateScreen(); } @@ -1093,7 +1096,11 @@ void GraphicsManager::resetVesaSegment() { _dirtyRects.clear(); } -// Add VESA Segment +void GraphicsManager::resetRefreshRects() { + _refreshRects.clear(); +} + +// Add a game area dirty rectangle void GraphicsManager::addDirtyRect(int x1, int y1, int x2, int y2) { x1 = CLIP(x1, _minX, _maxX); y1 = CLIP(y1, _minY, _maxY); @@ -1115,7 +1122,19 @@ void GraphicsManager::addDirtyRect(int x1, int y1, int x2, int y2) { _dirtyRects.push_back(newRect); } -// Display VESA Segment +// Add a refresh rect +void GraphicsManager::addRefreshRect(const Common::Rect &r) { + // Ensure that an existing dest rectangle doesn't already contain the new one + for (uint idx = 0; idx < _refreshRects.size(); ++idx) { + if (_refreshRects[idx].contains(r)) + return; + } + + assert(_refreshRects.size() < DIRTY_RECTS_SIZE); + _refreshRects.push_back(r); +} + +// Draw any game dirty rects onto the screen intermediate surface void GraphicsManager::displayVesaSegment() { if (_dirtyRects.size() == 0) return; @@ -1124,7 +1143,7 @@ void GraphicsManager::displayVesaSegment() { for (uint idx = 0; idx < _dirtyRects.size(); ++idx) { Common::Rect &r = _dirtyRects[idx]; - Common::Rect &dstRect = dstrect[idx]; + Common::Rect dstRect; if (_vm->_eventsManager._breakoutFl) { Copy_Vga16(_vesaBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left, r.top); @@ -1159,6 +1178,19 @@ void GraphicsManager::displayVesaSegment() { resetVesaSegment(); } +void GraphicsManager::displayRefreshRects() { + if (_refreshRects.size() == 0) + return; +/* + for (uint idx = 0; idx < _refreshRects.size(); ++idx) { + const Common::Rect &r = _refreshRects[idx]; + + g_system->copyRectToScreen(_screenBuffer, WinScan,) + } +*/ + resetRefreshRects(); +} + void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, int idx, bool addSegment) { int width = _vm->_objectsManager.getWidth(objectData, idx); int height = _vm->_objectsManager.getHeight(objectData, idx); -- cgit v1.2.3 From 95aca78bcdc42a2765220c2fbd990539168b15b5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Mar 2013 20:40:03 -0500 Subject: HOPKINS: Renamed dirty rect methods --- engines/hopkins/graphics.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 4fe9c4ef39..75280c48d7 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1092,7 +1092,7 @@ void GraphicsManager::displayAllBob() { } } -void GraphicsManager::resetVesaSegment() { +void GraphicsManager::resetDirtyRects() { _dirtyRects.clear(); } @@ -1135,7 +1135,7 @@ void GraphicsManager::addRefreshRect(const Common::Rect &r) { } // Draw any game dirty rects onto the screen intermediate surface -void GraphicsManager::displayVesaSegment() { +void GraphicsManager::displayDirtyRects() { if (_dirtyRects.size() == 0) return; @@ -1175,7 +1175,7 @@ void GraphicsManager::displayVesaSegment() { } unlockScreen(); - resetVesaSegment(); + resetDirtyRects(); } void GraphicsManager::displayRefreshRects() { -- cgit v1.2.3 From 9d8eb97840072ee2c55dabdaf07c05b4db086eea Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Mar 2013 20:57:42 -0500 Subject: HOPKINS: Hooked up display code for refresh rects --- engines/hopkins/graphics.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 75280c48d7..c7b6904335 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -162,6 +162,8 @@ void GraphicsManager::unlockScreen() { void GraphicsManager::clearScreen() { assert(_videoPtr); Common::fill(_videoPtr, _videoPtr + WinScan * _screenHeight, 0); + if (!_isPhysicalPtr) + addRefreshRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); } /** @@ -1179,15 +1181,14 @@ void GraphicsManager::displayDirtyRects() { } void GraphicsManager::displayRefreshRects() { - if (_refreshRects.size() == 0) - return; -/* + // Loop through copying over any specified rects to the screen for (uint idx = 0; idx < _refreshRects.size(); ++idx) { const Common::Rect &r = _refreshRects[idx]; - g_system->copyRectToScreen(_screenBuffer, WinScan,) + byte *srcP = _screenBuffer + WinScan * r.top + (r.left * 2); + g_system->copyRectToScreen(srcP, WinScan, r.left, r.top, r.width(), r.height()); } -*/ + resetRefreshRects(); } -- cgit v1.2.3 From 77eb6f74eb17deda5e629457ca4ec144782fddfe Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Mar 2013 21:47:03 -0500 Subject: HOPKINS: Fix to not display dirty rects that are off-screen --- engines/hopkins/graphics.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index c7b6904335..0c06ef7f48 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1171,9 +1171,12 @@ void GraphicsManager::displayDirtyRects() { unlockScreen(); } - byte *srcP = _videoPtr + WinScan * dstRect.top + (dstRect.left * 2); - g_system->copyRectToScreen(srcP, WinScan, dstRect.left, dstRect.top, - dstRect.width(), dstRect.height()); + // If it's a valid rect, then copy it over + if (dstRect.isValidRect() && dstRect.width() > 0 && dstRect.height() > 0) { + byte *srcP = _videoPtr + WinScan * dstRect.top + (dstRect.left * 2); + g_system->copyRectToScreen(srcP, WinScan, dstRect.left, dstRect.top, + dstRect.width(), dstRect.height()); + } } unlockScreen(); -- cgit v1.2.3 From 7a7b2b35e2be1e6526d8aeea2576e8c9231aa73c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Mar 2013 22:36:38 -0500 Subject: HOPKINS: Added a debugger command to frame dirty rects --- engines/hopkins/graphics.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 0c06ef7f48..540c18f1b4 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -51,6 +51,7 @@ GraphicsManager::GraphicsManager() { _vesaBuffer = NULL; _screenBuffer = NULL; _isPhysicalPtr = false; + _showDirtyRects = false; _lineNbr2 = 0; Agr_x = Agr_y = 0; @@ -1142,6 +1143,13 @@ void GraphicsManager::displayDirtyRects() { return; lockScreen(); + + // Refresh the entire screen + Graphics::Surface *screenSurface = NULL; + if (_showDirtyRects) { + screenSurface = g_system->lockScreen(); + g_system->copyRectToScreen(_screenBuffer, WinScan, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + } for (uint idx = 0; idx < _dirtyRects.size(); ++idx) { Common::Rect &r = _dirtyRects[idx]; @@ -1176,10 +1184,16 @@ void GraphicsManager::displayDirtyRects() { byte *srcP = _videoPtr + WinScan * dstRect.top + (dstRect.left * 2); g_system->copyRectToScreen(srcP, WinScan, dstRect.left, dstRect.top, dstRect.width(), dstRect.height()); + + if (_showDirtyRects) + screenSurface->frameRect(dstRect, 0xffffff); } } unlockScreen(); + if (_showDirtyRects) + g_system->unlockScreen(); + resetDirtyRects(); } -- cgit v1.2.3 From f93275b3109943a76bd75163d5f4e5bc2cee982c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 5 Mar 2013 09:42:06 -0500 Subject: HOPKINS: Removed usage of g_system->lockScreen --- engines/hopkins/graphics.cpp | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 540c18f1b4..ecefe4c73e 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -50,7 +50,6 @@ GraphicsManager::GraphicsManager() { _vesaScreen = NULL; _vesaBuffer = NULL; _screenBuffer = NULL; - _isPhysicalPtr = false; _showDirtyRects = false; _lineNbr2 = 0; @@ -127,19 +126,11 @@ void GraphicsManager::setGraphicalMode(int width, int height) { /** * (try to) Lock Screen */ -void GraphicsManager::lockScreen(bool shouldUsePhysicalScreen) { +void GraphicsManager::lockScreen() { if (!_skipVideoLockFl) { if (_lockCounter++ == 0) { - if (shouldUsePhysicalScreen) { - Graphics::Surface *s = g_system->lockScreen(); - _videoPtr = (byte *)s->pixels; - WinScan = s->pitch; - } else { - _videoPtr = _screenBuffer; - WinScan = SCREEN_WIDTH * 2; - } - - _isPhysicalPtr = shouldUsePhysicalScreen; + _videoPtr = _screenBuffer; + WinScan = SCREEN_WIDTH * 2; } } } @@ -150,9 +141,6 @@ void GraphicsManager::lockScreen(bool shouldUsePhysicalScreen) { void GraphicsManager::unlockScreen() { assert(_videoPtr); if (--_lockCounter == 0) { - if (_isPhysicalPtr) - g_system->unlockScreen(); - _videoPtr = NULL; } } @@ -163,8 +151,8 @@ void GraphicsManager::unlockScreen() { void GraphicsManager::clearScreen() { assert(_videoPtr); Common::fill(_videoPtr, _videoPtr + WinScan * _screenHeight, 0); - if (!_isPhysicalPtr) - addRefreshRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); + + addRefreshRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); } /** @@ -201,7 +189,7 @@ void GraphicsManager::loadVgaImage(const Common::String &file) { */ void GraphicsManager::loadScreen(const Common::String &file) { Common::File f; - assert(!_videoPtr || !_isPhysicalPtr); + assert(!_videoPtr); bool flag = true; if (_vm->_fileManager.searchCat(file, 6) == g_PTRNUL) { @@ -1198,14 +1186,25 @@ void GraphicsManager::displayDirtyRects() { } void GraphicsManager::displayRefreshRects() { + Graphics::Surface *screenSurface = NULL; + if (_showDirtyRects) { + screenSurface = g_system->lockScreen(); + g_system->copyRectToScreen(_screenBuffer, WinScan, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + } // Loop through copying over any specified rects to the screen for (uint idx = 0; idx < _refreshRects.size(); ++idx) { const Common::Rect &r = _refreshRects[idx]; byte *srcP = _screenBuffer + WinScan * r.top + (r.left * 2); g_system->copyRectToScreen(srcP, WinScan, r.left, r.top, r.width(), r.height()); + + if (_showDirtyRects) + screenSurface->frameRect(r, 0xffffff); } + if (_showDirtyRects) + g_system->unlockScreen(); + resetRefreshRects(); } -- cgit v1.2.3 From 188f7efd0584c975e9e5d2ae38752c7217083cb0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 5 Mar 2013 20:58:43 -0500 Subject: HOPKINS: Fix display of screen images using screen fade in --- engines/hopkins/graphics.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index ecefe4c73e..d4e1a25e9e 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -727,6 +727,7 @@ uint16 GraphicsManager::mapRGB(byte r, byte g, byte b) { void GraphicsManager::DD_VBL() { // Display any aras of the screen that need refreshing + displayDirtyRects(); displayRefreshRects(); // Update the screen -- cgit v1.2.3 From 83480c5784dd4193fa6b5dd3bb2f7a75ac67715d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 6 Mar 2013 09:46:05 -0500 Subject: HOPKINS: Fix transition between initial version display to intro animation --- engines/hopkins/graphics.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index d4e1a25e9e..f3116930a0 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -150,11 +150,18 @@ void GraphicsManager::unlockScreen() { */ void GraphicsManager::clearScreen() { assert(_videoPtr); - Common::fill(_videoPtr, _videoPtr + WinScan * _screenHeight, 0); + Common::fill(_screenBuffer, _screenBuffer + WinScan * _screenHeight, 0); addRefreshRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); } +void GraphicsManager::clearVesaScreen() { + warning("clearVesa"); + Common::fill(_vesaScreen, _vesaScreen + WinScan * _screenHeight, 0); + Common::fill(_vesaBuffer, _vesaBuffer + WinScan * _screenHeight, 0); + addDirtyRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); +} + /** * Load Image */ -- cgit v1.2.3 From 55c024494d80b343fc23d8e534153fd9c873f040 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Mar 2013 09:44:46 -0500 Subject: HOPKINS: Fix problem with scrolling not working properly --- engines/hopkins/graphics.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index f3116930a0..b5c0660a3a 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -152,11 +152,10 @@ void GraphicsManager::clearScreen() { assert(_videoPtr); Common::fill(_screenBuffer, _screenBuffer + WinScan * _screenHeight, 0); - addRefreshRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); + addRefreshRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); } void GraphicsManager::clearVesaScreen() { - warning("clearVesa"); Common::fill(_vesaScreen, _vesaScreen + WinScan * _screenHeight, 0); Common::fill(_vesaBuffer, _vesaBuffer + WinScan * _screenHeight, 0); addDirtyRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); @@ -439,7 +438,7 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, } unlockScreen(); - addDirtyRect(xs, ys, xs + width, ys + height); + addRefreshRect(xs, ys, xs + width, ys + height); } // TODO: See if PAL_PIXELS can be converted to a uint16 array @@ -499,7 +498,7 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width yNext = yCtr - 1; } while (yCtr != 1); - addDirtyRect(xs, ys, xs + width, ys + width); + addRefreshRect(xs, ys, xs + width, ys + width); } void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { @@ -538,7 +537,7 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, yCount = yCtr - 1; } while (yCtr != 1); - addDirtyRect(xp, yp, xp + width, yp + width); + addRefreshRect(xp, yp, xp + width, yp + width); } /** @@ -1122,15 +1121,18 @@ void GraphicsManager::addDirtyRect(int x1, int y1, int x2, int y2) { } // Add a refresh rect -void GraphicsManager::addRefreshRect(const Common::Rect &r) { - // Ensure that an existing dest rectangle doesn't already contain the new one - for (uint idx = 0; idx < _refreshRects.size(); ++idx) { - if (_refreshRects[idx].contains(r)) - return; - } +void GraphicsManager::addRefreshRect(int x1, int y1, int x2, int y2) { + x1 = MAX(x1, 0); + y1 = MAX(y1, 0); + x2 = MIN(x2, SCREEN_WIDTH); + y2 = MIN(y2, SCREEN_HEIGHT); - assert(_refreshRects.size() < DIRTY_RECTS_SIZE); - _refreshRects.push_back(r); + if ((x2 > x1) && (y2 > y1)) { + Common::Rect r(x1, y1, x2, y2); + + assert(_refreshRects.size() < DIRTY_RECTS_SIZE); + _refreshRects.push_back(r); + } } // Draw any game dirty rects onto the screen intermediate surface -- cgit v1.2.3 From 3d06a93be163d9cc99d5c06036408e3020d5e76e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Mar 2013 22:04:41 -0500 Subject: HOPKINS: Merged dirty/refresh rect rect adding into a single method --- engines/hopkins/graphics.cpp | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index b5c0660a3a..af142ac2c3 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1105,19 +1105,8 @@ void GraphicsManager::addDirtyRect(int x1, int y1, int x2, int y2) { x2 = CLIP(x2, _minX, _maxX); y2 = CLIP(y2, _minY, _maxY); - Common::Rect newRect(x1, y1, x2, y2); - if (!newRect.isValidRect()) - return; - - // Don't bother adding the rect if it's contained within another existing one - for (uint rectIndex = 0; rectIndex < _dirtyRects.size(); ++rectIndex) { - const Common::Rect &r = _dirtyRects[rectIndex]; - if (r.contains(newRect)) - return; - } - - assert(_dirtyRects.size() < DIRTY_RECTS_SIZE); - _dirtyRects.push_back(newRect); + if ((x2 > x1) && (y2 > y1)) + addRectToArray(_dirtyRects, Common::Rect(x1, y1, x2, y2)); } // Add a refresh rect @@ -1127,12 +1116,25 @@ void GraphicsManager::addRefreshRect(int x1, int y1, int x2, int y2) { x2 = MIN(x2, SCREEN_WIDTH); y2 = MIN(y2, SCREEN_HEIGHT); - if ((x2 > x1) && (y2 > y1)) { - Common::Rect r(x1, y1, x2, y2); + if ((x2 > x1) && (y2 > y1)) + addRectToArray(_refreshRects, Common::Rect(x1, y1, x2, y2)); +} - assert(_refreshRects.size() < DIRTY_RECTS_SIZE); - _refreshRects.push_back(r); +void GraphicsManager::addRectToArray(Common::Array &rects, const Common::Rect &newRect) { + // Scan for an intersection with existing rects + for (uint rectIndex = 0; rectIndex < rects.size(); ++rectIndex) { + Common::Rect &r = rects[rectIndex]; + + if (r.intersects(newRect)) { + // Rect either intersects or is completely inside existing one, so extend existing one as necessary + r.extend(newRect); + return; + } } + + // Ensure that the rect list doesn't get too big, and add the new one in + assert(_refreshRects.size() < DIRTY_RECTS_SIZE); + rects.push_back(newRect); } // Draw any game dirty rects onto the screen intermediate surface -- cgit v1.2.3 From e50a7be7defca39b89941a7bade023db87e6bf01 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Mar 2013 22:09:29 -0400 Subject: HOPKINS: Further fix for dirty area display in-game --- engines/hopkins/graphics.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index af142ac2c3..bad67603c5 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -438,7 +438,7 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, } unlockScreen(); - addRefreshRect(xs, ys, xs + width, ys + height); + addRefreshRect(destX, destY, destX + width, destY + height); } // TODO: See if PAL_PIXELS can be converted to a uint16 array @@ -498,7 +498,7 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width yNext = yCtr - 1; } while (yCtr != 1); - addRefreshRect(xs, ys, xs + width, ys + width); + addRefreshRect(destX, destY, destX + width, destY + width); } void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { @@ -537,7 +537,7 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, yCount = yCtr - 1; } while (yCtr != 1); - addRefreshRect(xp, yp, xp + width, yp + width); + addRefreshRect(destX, destY, destX + width, destY + width); } /** -- cgit v1.2.3 From f49fb723dafff9e8b9f213cff785e580c671a3a8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Mar 2013 22:15:12 -0400 Subject: HOPKINS: Added a more comprehensive rects merge code --- engines/hopkins/graphics.cpp | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index bad67603c5..326571828e 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -1122,19 +1122,39 @@ void GraphicsManager::addRefreshRect(int x1, int y1, int x2, int y2) { void GraphicsManager::addRectToArray(Common::Array &rects, const Common::Rect &newRect) { // Scan for an intersection with existing rects - for (uint rectIndex = 0; rectIndex < rects.size(); ++rectIndex) { + uint rectIndex; + for (rectIndex = 0; rectIndex < rects.size(); ++rectIndex) { Common::Rect &r = rects[rectIndex]; if (r.intersects(newRect)) { // Rect either intersects or is completely inside existing one, so extend existing one as necessary r.extend(newRect); - return; + break; } } + if (rectIndex == rects.size()) { + // Rect not intersecting any existing one, so add it in + assert(rects.size() < DIRTY_RECTS_SIZE); + rects.push_back(newRect); + } + + // Take care of merging the existing rect list. This is done as a separate check even if + // a previous extending above has been done, since the merging of the new rect above may + // result in further rects now able to be merged + + for (int srcIndex = rects.size() - 1; srcIndex > 0; --srcIndex) { + const Common::Rect &srcRect = rects[srcIndex]; - // Ensure that the rect list doesn't get too big, and add the new one in - assert(_refreshRects.size() < DIRTY_RECTS_SIZE); - rects.push_back(newRect); + // Loop through all the other rects to see if it intersects them + for (int destIndex = srcIndex - 1; destIndex >= 0; --destIndex) { + if (rects[destIndex].intersects(srcRect)) { + // Found an intersection, so extend the found one, and delete the original + rects[destIndex].extend(srcRect); + rects.remove_at(srcIndex); + break; + } + } + } } // Draw any game dirty rects onto the screen intermediate surface -- cgit v1.2.3 From 408345ebabe803f239e85d32a0627f5ca5c7b46b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 Mar 2013 21:43:48 -0400 Subject: HOPKINS: Further cleaned up dirty rect display --- engines/hopkins/graphics.cpp | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 326571828e..4041363814 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -185,6 +185,7 @@ void GraphicsManager::loadVgaImage(const Common::String &file) { lockScreen(); copy16bFromSurfaceScaleX2(_vesaBuffer); + addRefreshRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); unlockScreen(); fadeInBreakout(); @@ -1165,12 +1166,6 @@ void GraphicsManager::displayDirtyRects() { lockScreen(); // Refresh the entire screen - Graphics::Surface *screenSurface = NULL; - if (_showDirtyRects) { - screenSurface = g_system->lockScreen(); - g_system->copyRectToScreen(_screenBuffer, WinScan, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); - } - for (uint idx = 0; idx < _dirtyRects.size(); ++idx) { Common::Rect &r = _dirtyRects[idx]; Common::Rect dstRect; @@ -1199,21 +1194,12 @@ void GraphicsManager::displayDirtyRects() { unlockScreen(); } - // If it's a valid rect, then copy it over - if (dstRect.isValidRect() && dstRect.width() > 0 && dstRect.height() > 0) { - byte *srcP = _videoPtr + WinScan * dstRect.top + (dstRect.left * 2); - g_system->copyRectToScreen(srcP, WinScan, dstRect.left, dstRect.top, - dstRect.width(), dstRect.height()); - - if (_showDirtyRects) - screenSurface->frameRect(dstRect, 0xffffff); - } + // If it's a valid rect, then add it to the list of areas to refresh on the screen + if (dstRect.isValidRect() && dstRect.width() > 0 && dstRect.height() > 0) + addRectToArray(_refreshRects, dstRect); } unlockScreen(); - if (_showDirtyRects) - g_system->unlockScreen(); - resetDirtyRects(); } -- cgit v1.2.3 From 39ffd06839531cb9a2e81e9c89b820b6332327d8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 Mar 2013 22:58:48 -0400 Subject: HOPKINS: Bugfix for refreshing Breakout lives when one is lost --- engines/hopkins/graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/hopkins/graphics.cpp') diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 4041363814..798b350fcd 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -675,7 +675,7 @@ void GraphicsManager::fadeInBreakout() { /** * Fade out used by for the breakout mini-game */ -void GraphicsManager::fateOutBreakout() { +void GraphicsManager::fadeOutBreakout() { byte palette[PALETTE_EXT_BLOCK_SIZE]; memset(palette, 0, PALETTE_EXT_BLOCK_SIZE); -- cgit v1.2.3