Enable dirty rect handling for the Amiga version again.

svn-id: r43280
This commit is contained in:
Johannes Schickel 2009-08-11 16:46:38 +00:00
parent c1511d3b44
commit 1a59173a9b
2 changed files with 76 additions and 17 deletions

View File

@ -206,6 +206,8 @@ void Screen::setResolution() {
void Screen::updateScreen() {
if (_useOverlays)
updateDirtyRectsOvl();
else if (_isAmiga && _interfacePaletteEnabled)
updateDirtyRectsAmiga();
else
updateDirtyRects();
@ -220,9 +222,21 @@ void Screen::updateScreen() {
}
void Screen::updateDirtyRects() {
// TODO: Enable dirty rect handling for the AMIGA version
if (_forceFullUpdate || _isAmiga) {
if (_interfacePaletteEnabled) {
if (_forceFullUpdate) {
_system->copyRectToScreen(getCPagePtr(0), SCREEN_W, 0, 0, SCREEN_W, SCREEN_H);
} else {
const byte *page0 = getCPagePtr(0);
Common::List<Common::Rect>::iterator it;
for (it = _dirtyRects.begin(); it != _dirtyRects.end(); ++it) {
_system->copyRectToScreen(page0 + it->top * SCREEN_W + it->left, SCREEN_W, it->left, it->top, it->width(), it->height());
}
}
_forceFullUpdate = false;
_dirtyRects.clear();
}
void Screen::updateDirtyRectsAmiga() {
if (_forceFullUpdate) {
_system->copyRectToScreen(getCPagePtr(0), SCREEN_W, 0, 0, SCREEN_W, 136);
// Page 8 is not used by Kyra 1 AMIGA, thus we can use it to adjust the colors
@ -234,16 +248,60 @@ void Screen::updateDirtyRects() {
*dst++ += 32;
_system->copyRectToScreen(getCPagePtr(8), SCREEN_W, 0, 136, SCREEN_W, 64);
} else {
_system->copyRectToScreen(getCPagePtr(0), SCREEN_W, 0, 0, SCREEN_W, SCREEN_H);
}
} else {
const byte *page0 = getCPagePtr(0);
Common::List<Common::Rect>::iterator it;
for (it = _dirtyRects.begin(); it != _dirtyRects.end(); ++it) {
if (it->bottom <= 136) {
_system->copyRectToScreen(page0 + it->top * SCREEN_W + it->left, SCREEN_W, it->left, it->top, it->width(), it->height());
} else {
// Check whether the rectangle is part of both the screen and the interface
if (it->top < 136) {
// The rectangle covers both screen part and interface part
const int screenHeight = 136 - it->top;
const int interfaceHeight = it->bottom - 136;
const int width = it->width();
const int lineAdd = SCREEN_W - width;
// Copy the screen part verbatim
_system->copyRectToScreen(page0 + it->top * SCREEN_W + it->left, SCREEN_W, it->left, it->top, width, screenHeight);
// Adjust the interface part
copyRegion(it->left, 136, 0, 0, width, interfaceHeight, 0, 8, Screen::CR_NO_P_CHECK);
uint8 *dst = getPagePtr(8);
for (int y = 0; y < interfaceHeight; ++y) {
for (int x = 0; x < width; ++x)
*dst++ += 32;
dst += lineAdd;
}
_system->copyRectToScreen(getCPagePtr(8), SCREEN_W, it->left, 136, width, interfaceHeight);
} else {
// The rectangle only covers the interface part
const int width = it->width();
const int height = it->height();
const int lineAdd = SCREEN_W - width;
copyRegion(it->left, it->top, 0, 0, width, height, 0, 8, Screen::CR_NO_P_CHECK);
uint8 *dst = getPagePtr(8);
for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x)
*dst++ += 32;
dst += lineAdd;
}
_system->copyRectToScreen(getCPagePtr(8), SCREEN_W, it->left, it->top, width, height);
}
}
}
}
_forceFullUpdate = false;
_dirtyRects.clear();
}

View File

@ -452,6 +452,7 @@ public:
protected:
uint8 *getPagePtr(int pageNum);
void updateDirtyRects();
void updateDirtyRectsAmiga();
void updateDirtyRectsOvl();
void scale2x(byte *dst, int dstPitch, const byte *src, int srcPitch, int w, int h);