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/computer.cpp | 6 +++--- engines/hopkins/dialogs.cpp | 22 +++++++++++----------- engines/hopkins/events.cpp | 2 +- engines/hopkins/font.cpp | 6 +++--- engines/hopkins/graphics.cpp | 21 +++++++++++---------- engines/hopkins/graphics.h | 2 +- engines/hopkins/objects.cpp | 20 ++++++++++---------- 7 files changed, 40 insertions(+), 39 deletions(-) (limited to 'engines') diff --git a/engines/hopkins/computer.cpp b/engines/hopkins/computer.cpp index 2e911152bb..37f1dd2ec7 100644 --- a/engines/hopkins/computer.cpp +++ b/engines/hopkins/computer.cpp @@ -426,13 +426,13 @@ void ComputerManager::displayMessage(int xp, int yp, int textIdx) { x1 -= _vm->_fontManager._fontFixedWidth; x2 = x1 + 2 * _vm->_fontManager._fontFixedWidth; _vm->_graphicsManager.Copy_Mem(_vm->_graphicsManager._vesaScreen, x1, yp, 3 * _vm->_fontManager._fontFixedWidth, 12, _vm->_graphicsManager._vesaBuffer, x1, yp); - _vm->_graphicsManager.addVesaSegment(x1, yp, x2, yp + 12); + _vm->_graphicsManager.addDirtyRect(x1, yp, x2, yp + 12); _vm->_fontManager.displayTextVesa(x1, yp, "_", 252); } if (mappedChar != '*') { char newChar = mappedChar; _vm->_graphicsManager.Copy_Mem(_vm->_graphicsManager._vesaScreen, x1, yp, _vm->_fontManager._fontFixedWidth, 12, _vm->_graphicsManager._vesaBuffer, x1, yp); - _vm->_graphicsManager.addVesaSegment(x1, yp, _vm->_fontManager._fontFixedWidth + x1, yp + 12); + _vm->_graphicsManager.addDirtyRect(x1, yp, _vm->_fontManager._fontFixedWidth + x1, yp + 12); _inputBuf[textIndex] = newChar; Common::String charString = Common::String::format("%c_", newChar); @@ -444,7 +444,7 @@ void ComputerManager::displayMessage(int xp, int yp, int textIdx) { } while (textIndex != textIdx && curChar != 13); _vm->_graphicsManager.Copy_Mem(_vm->_graphicsManager._vesaScreen, x1, yp, _vm->_fontManager._fontFixedWidth, 12, _vm->_graphicsManager._vesaBuffer, x1, yp); - _vm->_graphicsManager.addVesaSegment(x1, yp, _vm->_fontManager._fontFixedWidth + x1, yp + 12); + _vm->_graphicsManager.addDirtyRect(x1, yp, _vm->_fontManager._fontFixedWidth + x1, yp + 12); _vm->_eventsManager.VBL(); _inputBuf[textIndex] = 0; diff --git a/engines/hopkins/dialogs.cpp b/engines/hopkins/dialogs.cpp index 6102c8645a..f45e58644a 100644 --- a/engines/hopkins/dialogs.cpp +++ b/engines/hopkins/dialogs.cpp @@ -300,7 +300,7 @@ void DialogsManager::showOptionsDialog() { _vm->_graphicsManager.copySurface(_vm->_graphicsManager._vesaScreen, _vm->_graphicsManager._scrollOffset + 164, 107, 335, 215, _vm->_graphicsManager._vesaBuffer, _vm->_graphicsManager._scrollOffset + 164, 107); - _vm->_graphicsManager.addVesaSegment(_vm->_graphicsManager._scrollOffset + 164, 107, + _vm->_graphicsManager.addDirtyRect(_vm->_graphicsManager._scrollOffset + 164, 107, _vm->_graphicsManager._scrollOffset + 498, 320); _vm->_globals._optionDialogSpr = _vm->_globals.freeMemory(_vm->_globals._optionDialogSpr); @@ -451,7 +451,7 @@ void DialogsManager::showInventory() { if (_inventDisplayedFl) { _inventDisplayedFl = false; _vm->_graphicsManager.copySurface(_vm->_graphicsManager._vesaScreen, _inventX, 114, _inventWidth, _inventHeight, _vm->_graphicsManager._vesaBuffer, _inventX, 114); - _vm->_graphicsManager.addVesaSegment(_inventX, 114, _inventX + _inventWidth, _inventWidth + 114); + _vm->_graphicsManager.addDirtyRect(_inventX, 114, _inventX + _inventWidth, _inventWidth + 114); _vm->_objectsManager.BOBTOUS = true; } @@ -483,7 +483,7 @@ void DialogsManager::inventAnim() { if (_vm->_objectsManager._eraseVisibleCounter && !_vm->_objectsManager._visibleFl) { _vm->_graphicsManager.copySurface(_vm->_graphicsManager._vesaScreen, _vm->_objectsManager._oldInventoryPosX, 27, 48, 38, _vm->_graphicsManager._vesaBuffer, _vm->_objectsManager._oldInventoryPosX, 27); - _vm->_graphicsManager.addVesaSegment(_vm->_objectsManager._oldInventoryPosX, 27, _vm->_objectsManager._oldInventoryPosX + 48, 65); + _vm->_graphicsManager.addDirtyRect(_vm->_objectsManager._oldInventoryPosX, 27, _vm->_objectsManager._oldInventoryPosX + 48, 65); --_vm->_objectsManager._eraseVisibleCounter; } @@ -493,10 +493,10 @@ void DialogsManager::inventAnim() { _vm->_graphicsManager.copySurface(_vm->_graphicsManager._vesaScreen, _vm->_objectsManager._oldInventoryPosX, 27, 48, 38, _vm->_graphicsManager._vesaBuffer, _vm->_objectsManager._oldInventoryPosX, 27); - _vm->_graphicsManager.addVesaSegment(_vm->_objectsManager._oldInventoryPosX, 27, _vm->_objectsManager._oldInventoryPosX + 48, 65); + _vm->_graphicsManager.addDirtyRect(_vm->_objectsManager._oldInventoryPosX, 27, _vm->_objectsManager._oldInventoryPosX + 48, 65); int newOffset = _vm->_graphicsManager._scrollOffset + 2; _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager._vesaBuffer, _inventoryIcons, newOffset + 300, 327, 0); - _vm->_graphicsManager.addVesaSegment(newOffset, 27, newOffset + 45, 62); + _vm->_graphicsManager.addDirtyRect(newOffset, 27, newOffset + 45, 62); _vm->_objectsManager._oldInventoryPosX = newOffset; } @@ -505,17 +505,17 @@ void DialogsManager::inventAnim() { _vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager._vesaBuffer, _vm->_objectsManager._headSprites, 832, 325, 0, 0, 0, false); if (_vm->_globals._saveData->_data[svField355] == 1) _vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager._vesaBuffer, _vm->_objectsManager._headSprites, 866, 325, 1, 0, 0, false); - _vm->_graphicsManager.addVesaSegment(532, 25, 560, 60); - _vm->_graphicsManager.addVesaSegment(566, 25, 594, 60); + _vm->_graphicsManager.addDirtyRect(532, 25, 560, 60); + _vm->_graphicsManager.addDirtyRect(566, 25, 594, 60); } if (_vm->_globals._saveData->_data[svField356] == 1) { _vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager._vesaBuffer, _vm->_objectsManager._headSprites, 832, 325, 0, 0, 0, false); - _vm->_graphicsManager.addVesaSegment(532, 25, 560, 60); + _vm->_graphicsManager.addDirtyRect(532, 25, 560, 60); } if (_vm->_globals._saveData->_data[svField354] == 1) { _vm->_graphicsManager.Affiche_Perfect(_vm->_graphicsManager._vesaBuffer, _vm->_objectsManager._headSprites, 832, 325, 0, 0, 0, false); - _vm->_graphicsManager.addVesaSegment(532, 25, 560, 60); + _vm->_graphicsManager.addDirtyRect(532, 25, 560, 60); } } @@ -574,7 +574,7 @@ void DialogsManager::showLoadGame() { } while (!_vm->shouldQuit() && (!slotNumber || _vm->_eventsManager.getMouseButton() != 1)); _vm->_objectsManager._saveLoadFl = false; _vm->_graphicsManager.copySurface(_vm->_graphicsManager._vesaScreen, _vm->_eventsManager._startPos.x + 183, 60, 274, 353, _vm->_graphicsManager._vesaBuffer, _vm->_eventsManager._startPos.x + 183, 60); - _vm->_graphicsManager.addVesaSegment(_vm->_eventsManager._startPos.x + 183, 60, 457, 413); + _vm->_graphicsManager.addDirtyRect(_vm->_eventsManager._startPos.x + 183, 60, 457, 413); _vm->_objectsManager.BOBTOUS = true; _vm->_objectsManager._saveLoadSprite = _vm->_globals.freeMemory(_vm->_objectsManager._saveLoadSprite); _vm->_objectsManager._saveLoadSprite2 = _vm->_globals.freeMemory(_vm->_objectsManager._saveLoadSprite2); @@ -603,7 +603,7 @@ void DialogsManager::showSaveGame() { _vm->_objectsManager._saveLoadFl = false; _vm->_graphicsManager.copySurface(_vm->_graphicsManager._vesaScreen, _vm->_eventsManager._startPos.x + 183, 60, 274, 353, _vm->_graphicsManager._vesaBuffer, _vm->_eventsManager._startPos.x + 183, 60); - _vm->_graphicsManager.addVesaSegment(_vm->_eventsManager._startPos.x + 183, 60, _vm->_eventsManager._startPos.x + 457, 413); + _vm->_graphicsManager.addDirtyRect(_vm->_eventsManager._startPos.x + 183, 60, _vm->_eventsManager._startPos.x + 457, 413); _vm->_objectsManager.BOBTOUS = true; _vm->_objectsManager._saveLoadSprite = _vm->_globals.freeMemory(_vm->_objectsManager._saveLoadSprite); _vm->_objectsManager._saveLoadSprite2 = _vm->_globals.freeMemory(_vm->_objectsManager._saveLoadSprite2); diff --git a/engines/hopkins/events.cpp b/engines/hopkins/events.cpp index d13f545eb5..3a6d31accd 100644 --- a/engines/hopkins/events.cpp +++ b/engines/hopkins/events.cpp @@ -411,7 +411,7 @@ void EventsManager::VBL() { } } else if (yp < _vm->_graphicsManager._maxY && xp < _vm->_graphicsManager._maxX && width > 1 && height > 1) { _vm->_eventsManager.updateCursor(); - _vm->_graphicsManager.addVesaSegment(xp, yp, right, bottom); + _vm->_graphicsManager.addDirtyRect(xp, yp, right, bottom); } _vm->_globals._speed = 2; diff --git a/engines/hopkins/font.cpp b/engines/hopkins/font.cpp index 89d197b46b..62ce7f2a68 100644 --- a/engines/hopkins/font.cpp +++ b/engines/hopkins/font.cpp @@ -166,7 +166,7 @@ void FontManager::box(int idx, int messageId, const Common::String &filename, in yp, _text[idx]._width, _text[idx]._height); - _vm->_graphicsManager.addVesaSegment(xp, yp, xp + width, yp + height); + _vm->_graphicsManager.addDirtyRect(xp, yp, xp + width, yp + height); } } else { int lineCount = 0; @@ -405,7 +405,7 @@ void FontManager::displayTextVesa(int xp, int yp, const Common::String &message, } } - _vm->_graphicsManager.addVesaSegment(xp, yp, currentX, yp + 12); + _vm->_graphicsManager.addDirtyRect(xp, yp, currentX, yp + 12); } /** @@ -463,7 +463,7 @@ void FontManager::renderTextDisplay(int xp, int yp, const Common::String &msg, i int charStartPosX = charEndPosX; charEndPosX += charWidth; - _vm->_graphicsManager.addVesaSegment(charStartPosX, yp, charEndPosX, yp + 12); + _vm->_graphicsManager.addDirtyRect(charStartPosX, yp, charEndPosX, yp + 12); if (_vm->_eventsManager._escKeyFl) { _vm->_globals.iRegul = 1; _vm->_eventsManager.VBL(); 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); } } diff --git a/engines/hopkins/graphics.h b/engines/hopkins/graphics.h index c0d14f06e0..0db51a09a1 100644 --- a/engines/hopkins/graphics.h +++ b/engines/hopkins/graphics.h @@ -126,7 +126,7 @@ public: void unlockScreen(); void clearPalette(); void clearScreen(); - void addVesaSegment(int x1, int y1, int x2, int y2); + void addDirtyRect(int x1, int y1, int x2, int y2); void copySurface(const byte *surface, int x1, int y1, int width, int height, byte *destSurface, int destX, int destY); void loadImage(const Common::String &file); void loadVgaImage(const Common::String &file); diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp index b37dac2f6e..20d14af54d 100644 --- a/engines/hopkins/objects.cpp +++ b/engines/hopkins/objects.cpp @@ -414,7 +414,7 @@ void ObjectsManager::displaySprite() { _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager._vesaBuffer, _vm->_dialogsManager._inventBuf2, _oldBorderPos.x + 300, _oldBorderPos.y + 300, _oldBorderSpriteIndex + 1); if (_borderPos.x && _borderPos.y) _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager._vesaBuffer, _vm->_dialogsManager._inventBuf2, _borderPos.x + 300, _borderPos.y + 300, _borderSpriteIndex); - _vm->_graphicsManager.addVesaSegment(_vm->_dialogsManager._inventX, _vm->_dialogsManager._inventY, _vm->_dialogsManager._inventX + _vm->_dialogsManager._inventWidth, _vm->_dialogsManager._inventY + _vm->_dialogsManager._inventHeight); + _vm->_graphicsManager.addDirtyRect(_vm->_dialogsManager._inventX, _vm->_dialogsManager._inventY, _vm->_dialogsManager._inventX + _vm->_dialogsManager._inventWidth, _vm->_dialogsManager._inventY + _vm->_dialogsManager._inventHeight); } if (_saveLoadFl) { @@ -422,7 +422,7 @@ void ObjectsManager::displaySprite() { if (_saveLoadX && _saveLoadY) _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager._vesaBuffer, _saveLoadSprite2, _saveLoadX + _vm->_eventsManager._startPos.x + 300, _saveLoadY + 300, 0); - _vm->_graphicsManager.addVesaSegment(_vm->_eventsManager._startPos.x + 183, 60, _vm->_eventsManager._startPos.x + 457, 413); + _vm->_graphicsManager.addDirtyRect(_vm->_eventsManager._startPos.x + 183, 60, _vm->_eventsManager._startPos.x + 457, 413); } // If the Options dialog is activated, draw the elements @@ -443,7 +443,7 @@ void ObjectsManager::displaySprite() { _vm->_eventsManager._startPos.x + 600, 522, _vm->_globals._menuDisplayType); _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager._vesaBuffer, _vm->_globals._optionDialogSpr, _vm->_eventsManager._startPos.x + 611, 502, _vm->_globals._menuScrollSpeed); - _vm->_graphicsManager.addVesaSegment(_vm->_eventsManager._startPos.x + 164, 107, _vm->_eventsManager._startPos.x + 498, 320); + _vm->_graphicsManager.addDirtyRect(_vm->_eventsManager._startPos.x + 164, 107, _vm->_eventsManager._startPos.x + 498, 320); } // Loop to draw any on-screen text @@ -565,7 +565,7 @@ void ObjectsManager::setBobInfo(int idx) { _vm->_globals.Liste2[idx]._visibleFl = false; if (_vm->_globals.Liste2[idx]._visibleFl) - _vm->_graphicsManager.addVesaSegment( + _vm->_graphicsManager.addDirtyRect( _vm->_globals.Liste2[idx]._posX, _vm->_globals.Liste2[idx]._posY, _vm->_globals.Liste2[idx]._posX + _vm->_globals.Liste2[idx]._width, @@ -808,7 +808,7 @@ void ObjectsManager::DEF_SPRITE(int idx) { list->_visibleFl = false; if (list->_visibleFl) - _vm->_graphicsManager.addVesaSegment( list->_posX, list->_posY, list->_posX + list->_width, list->_posY + list->_height); + _vm->_graphicsManager.addDirtyRect( list->_posX, list->_posY, list->_posX + list->_width, list->_posY + list->_height); } void ObjectsManager::displayHiding(int idx) { @@ -816,7 +816,7 @@ void ObjectsManager::displayHiding(int idx) { _vm->_graphicsManager.Sprite_Vesa(_vm->_graphicsManager._vesaBuffer, _vm->_globals._hidingItemData[1], hid->_x + 300, hid->_y + 300, hid->_spriteIndex); - _vm->_graphicsManager.addVesaSegment(hid->_x, hid->_y, hid->_x + hid->_width, hid->_y + hid->_height); + _vm->_graphicsManager.addDirtyRect(hid->_x, hid->_y, hid->_x + hid->_width, hid->_y + hid->_height); } // Compute Sprite @@ -1085,7 +1085,7 @@ void ObjectsManager::displayVBob() { _vm->_graphicsManager.restoreSurfaceRect(_vm->_graphicsManager._vesaBuffer, vbob->_surface, vbob->_xp, vbob->_yp, width, height); - _vm->_graphicsManager.addVesaSegment(vbob->_xp, vbob->_yp, vbob->_xp + width, height + vbob->_yp); + _vm->_graphicsManager.addDirtyRect(vbob->_xp, vbob->_yp, vbob->_xp + width, height + vbob->_yp); vbob->_surface = _vm->_globals.freeMemory(vbob->_surface); vbob->field4 = 0; @@ -1109,7 +1109,7 @@ void ObjectsManager::displayVBob() { _vm->_graphicsManager.restoreSurfaceRect(_vm->_graphicsManager._vesaBuffer, vbob->_surface, vbob->_oldX, vbob->_oldY, width, height); - _vm->_graphicsManager.addVesaSegment(vbob->_oldX, vbob->_oldY, vbob->_oldX + width, vbob->_oldY + height); + _vm->_graphicsManager.addDirtyRect(vbob->_oldX, vbob->_oldY, vbob->_oldX + width, vbob->_oldY + height); vbob->field4 = 1; vbob->_oldSpriteData = vbob->_spriteData; @@ -1148,7 +1148,7 @@ void ObjectsManager::displayVBob() { vbob->_xp + 300, vbob->_yp + 300, vbob->_frameIndex); } - _vm->_graphicsManager.addVesaSegment(vbob->_xp, vbob->_yp , vbob->_xp + width, vbob->_yp + height); + _vm->_graphicsManager.addDirtyRect(vbob->_xp, vbob->_yp , vbob->_xp + width, vbob->_yp + height); vbob->field4 = 2; } } @@ -2095,7 +2095,7 @@ void ObjectsManager::changeCharacterHead(PlayerCharacter oldCharacter, PlayerCha _changeHeadFl = true; _vm->_graphicsManager.copySurface(_vm->_graphicsManager._vesaScreen, 532, 25, 65, 40, _vm->_graphicsManager._vesaBuffer, 532, 25); - _vm->_graphicsManager.addVesaSegment(532, 25, 597, 65); + _vm->_graphicsManager.addDirtyRect(532, 25, 597, 65); _vm->_globals._checkDistanceFl = true; _vm->_linesManager._route = (RouteItem *)g_PTRNUL; -- cgit v1.2.3