mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-19 08:06:42 +00:00
HOPKINS: Converted dirty rects to use Common::Array
This commit is contained in:
parent
c3bab0aecb
commit
d738802bc1
@ -47,7 +47,6 @@ GraphicsManager::GraphicsManager() {
|
|||||||
_scrollPosX = 0;
|
_scrollPosX = 0;
|
||||||
_largeScreenFl = false;
|
_largeScreenFl = false;
|
||||||
_oldScrollPosX = 0;
|
_oldScrollPosX = 0;
|
||||||
_dirtyRectCount = 0;
|
|
||||||
_vesaScreen = NULL;
|
_vesaScreen = NULL;
|
||||||
_vesaBuffer = NULL;
|
_vesaBuffer = NULL;
|
||||||
_screenBuffer = NULL;
|
_screenBuffer = NULL;
|
||||||
@ -76,10 +75,6 @@ GraphicsManager::GraphicsManager() {
|
|||||||
Common::fill(&_colorTable[0], &_colorTable[PALETTE_EXT_BLOCK_SIZE], 0);
|
Common::fill(&_colorTable[0], &_colorTable[PALETTE_EXT_BLOCK_SIZE], 0);
|
||||||
Common::fill(&_palette[0], &_palette[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);
|
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() {
|
GraphicsManager::~GraphicsManager() {
|
||||||
@ -1095,72 +1090,62 @@ void GraphicsManager::displayAllBob() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsManager::resetVesaSegment() {
|
void GraphicsManager::resetVesaSegment() {
|
||||||
for (int idx = 0; idx <= _dirtyRectCount; idx++)
|
_dirtyRects.clear();
|
||||||
_dirtyRects[idx]._activeFl = false;
|
|
||||||
|
|
||||||
_dirtyRectCount = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add VESA Segment
|
// Add VESA Segment
|
||||||
void GraphicsManager::addDirtyRect(int x1, int y1, int x2, int y2) {
|
void GraphicsManager::addDirtyRect(int x1, int y1, int x2, int y2) {
|
||||||
bool addFlag = true;
|
|
||||||
|
|
||||||
x1 = CLIP(x1, _minX, _maxX);
|
x1 = CLIP(x1, _minX, _maxX);
|
||||||
y1 = CLIP(y1, _minY, _maxY);
|
y1 = CLIP(y1, _minY, _maxY);
|
||||||
x2 = CLIP(x2, _minX, _maxX);
|
x2 = CLIP(x2, _minX, _maxX);
|
||||||
y2 = CLIP(y2, _minY, _maxY);
|
y2 = CLIP(y2, _minY, _maxY);
|
||||||
|
|
||||||
for (int blocIndex = 0; blocIndex <= _dirtyRectCount; blocIndex++) {
|
Common::Rect newRect(x1, y1, x2, y2);
|
||||||
BlocItem &bloc = _dirtyRects[blocIndex];
|
if (!newRect.isValidRect())
|
||||||
if (bloc._activeFl && x1 >= bloc._x1 && x2 <= bloc._x2 && y1 >= bloc._y1 && y2 <= bloc._y2)
|
return;
|
||||||
addFlag = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (addFlag && (x2 > x1) && (y2 > y1)) {
|
// Don't bother adding the rect if it's contained within another existing one
|
||||||
assert(_dirtyRectCount < DIRTY_RECTS_SIZE);
|
for (uint rectIndex = 0; rectIndex < _dirtyRects.size(); ++rectIndex) {
|
||||||
BlocItem &bloc = _dirtyRects[++_dirtyRectCount];
|
const Common::Rect &r = _dirtyRects[rectIndex];
|
||||||
|
if (r.contains(newRect))
|
||||||
bloc._activeFl = true;
|
return;
|
||||||
bloc._x1 = x1;
|
|
||||||
bloc._x2 = x2;
|
|
||||||
bloc._y1 = y1;
|
|
||||||
bloc._y2 = y2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(_dirtyRects.size() < DIRTY_RECTS_SIZE);
|
||||||
|
_dirtyRects.push_back(newRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display VESA Segment
|
// Display VESA Segment
|
||||||
void GraphicsManager::displayVesaSegment() {
|
void GraphicsManager::displayVesaSegment() {
|
||||||
if (_dirtyRectCount == 0)
|
if (_dirtyRects.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lockScreen();
|
lockScreen();
|
||||||
|
|
||||||
for (int idx = 1; idx <= _dirtyRectCount; ++idx) {
|
for (uint idx = 0; idx < _dirtyRects.size(); ++idx) {
|
||||||
BlocItem &bloc = _dirtyRects[idx];
|
Common::Rect &r = _dirtyRects[idx];
|
||||||
Common::Rect &dstRect = dstrect[idx - 1];
|
Common::Rect &dstRect = dstrect[idx];
|
||||||
if (!bloc._activeFl)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (_vm->_eventsManager._breakoutFl) {
|
if (_vm->_eventsManager._breakoutFl) {
|
||||||
Copy_Vga16(_vesaBuffer, bloc._x1, bloc._y1, bloc._x2 - bloc._x1, bloc._y2 - bloc._y1, bloc._x1, bloc._y1);
|
Copy_Vga16(_vesaBuffer, r.left, r.top, r.right - r.left, r.bottom - r.top, r.left, r.top);
|
||||||
dstRect.left = bloc._x1 * 2;
|
dstRect.left = r.left * 2;
|
||||||
dstRect.top = bloc._y1 * 2 + 30;
|
dstRect.top = r.top * 2 + 30;
|
||||||
dstRect.setWidth((bloc._x2 - bloc._x1) * 2);
|
dstRect.setWidth((r.right - r.left) * 2);
|
||||||
dstRect.setHeight((bloc._y2 - bloc._y1) * 2);
|
dstRect.setHeight((r.bottom - r.top) * 2);
|
||||||
} else if (bloc._x2 > _vm->_eventsManager._startPos.x && bloc._x1 < _vm->_eventsManager._startPos.x + SCREEN_WIDTH) {
|
} else if (r.right > _vm->_eventsManager._startPos.x && r.left < _vm->_eventsManager._startPos.x + SCREEN_WIDTH) {
|
||||||
if (bloc._x1 < _vm->_eventsManager._startPos.x)
|
if (r.left < _vm->_eventsManager._startPos.x)
|
||||||
bloc._x1 = _vm->_eventsManager._startPos.x;
|
r.left = _vm->_eventsManager._startPos.x;
|
||||||
if (bloc._x2 > _vm->_eventsManager._startPos.x + SCREEN_WIDTH)
|
if (r.right > _vm->_eventsManager._startPos.x + SCREEN_WIDTH)
|
||||||
bloc._x2 = _vm->_eventsManager._startPos.x + SCREEN_WIDTH;
|
r.right = _vm->_eventsManager._startPos.x + SCREEN_WIDTH;
|
||||||
|
|
||||||
// WORKAROUND: Original didn't lock the screen for access
|
// WORKAROUND: Original didn't lock the screen for access
|
||||||
lockScreen();
|
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.left = r.left - _vm->_eventsManager._startPos.x;
|
||||||
dstRect.top = bloc._y1;
|
dstRect.top = r.top;
|
||||||
dstRect.setWidth(bloc._x2 - bloc._x1);
|
dstRect.setWidth(r.right - r.left);
|
||||||
dstRect.setHeight(bloc._y2 - bloc._y1);
|
dstRect.setHeight(r.bottom - r.top);
|
||||||
|
|
||||||
unlockScreen();
|
unlockScreen();
|
||||||
}
|
}
|
||||||
@ -1168,12 +1153,10 @@ void GraphicsManager::displayVesaSegment() {
|
|||||||
byte *srcP = _videoPtr + WinScan * dstRect.top + (dstRect.left * 2);
|
byte *srcP = _videoPtr + WinScan * dstRect.top + (dstRect.left * 2);
|
||||||
g_system->copyRectToScreen(srcP, WinScan, dstRect.left, dstRect.top,
|
g_system->copyRectToScreen(srcP, WinScan, dstRect.left, dstRect.top,
|
||||||
dstRect.width(), dstRect.height());
|
dstRect.width(), dstRect.height());
|
||||||
|
|
||||||
_dirtyRects[idx]._activeFl = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unlockScreen();
|
unlockScreen();
|
||||||
_dirtyRectCount = 0;
|
resetVesaSegment();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, int idx, bool addSegment) {
|
void GraphicsManager::AFFICHE_SPEEDVGA(const byte *objectData, int xp, int yp, int idx, bool addSegment) {
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#define HOPKINS_GRAPHICS_H
|
#define HOPKINS_GRAPHICS_H
|
||||||
|
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
|
#include "common/array.h"
|
||||||
#include "common/endian.h"
|
#include "common/endian.h"
|
||||||
#include "common/rect.h"
|
#include "common/rect.h"
|
||||||
#include "common/str.h"
|
#include "common/str.h"
|
||||||
@ -46,14 +47,6 @@ struct RGB8 {
|
|||||||
byte b;
|
byte b;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BlocItem {
|
|
||||||
uint16 _activeFl;
|
|
||||||
int _x1;
|
|
||||||
int _y1;
|
|
||||||
int _x2;
|
|
||||||
int _y2;
|
|
||||||
};
|
|
||||||
|
|
||||||
class HopkinsEngine;
|
class HopkinsEngine;
|
||||||
|
|
||||||
class GraphicsManager {
|
class GraphicsManager {
|
||||||
@ -111,8 +104,7 @@ public:
|
|||||||
bool _skipVideoLockFl;
|
bool _skipVideoLockFl;
|
||||||
int _fadeDefaultSpeed;
|
int _fadeDefaultSpeed;
|
||||||
|
|
||||||
int _dirtyRectCount;
|
Common::Array<Common::Rect> _dirtyRects;
|
||||||
BlocItem _dirtyRects[DIRTY_RECTS_SIZE];
|
|
||||||
int WinScan;
|
int WinScan;
|
||||||
byte *PAL_PIXELS;
|
byte *PAL_PIXELS;
|
||||||
bool MANU_SCROLL;
|
bool MANU_SCROLL;
|
||||||
|
@ -2337,7 +2337,7 @@ int ScriptManager::handleOpcode(byte *dataP) {
|
|||||||
memcpy(_vm->_graphicsManager._oldPalette, _vm->_graphicsManager._palette, 769);
|
memcpy(_vm->_graphicsManager._oldPalette, _vm->_graphicsManager._palette, 769);
|
||||||
_vm->_animationManager.playAnim2("PLAN.ANM", 50, 10, 800);
|
_vm->_animationManager.playAnim2("PLAN.ANM", 50, 10, 800);
|
||||||
}
|
}
|
||||||
_vm->_graphicsManager._dirtyRectCount = 0;
|
_vm->_graphicsManager.resetVesaSegment();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 608:
|
case 608:
|
||||||
|
Loading…
Reference in New Issue
Block a user