diff options
author | Max Horn | 2007-07-08 22:13:50 +0000 |
---|---|---|
committer | Max Horn | 2007-07-08 22:13:50 +0000 |
commit | 0a662bfb7e057b0d5302a78687387543836c8c32 (patch) | |
tree | d82fc2ad195dfd6c8e1a1e183b171ce918a3ccf6 | |
parent | 14244685f3674f156a202dcb87bc3c01678e12f2 (diff) | |
download | scummvm-rg350-0a662bfb7e057b0d5302a78687387543836c8c32.tar.gz scummvm-rg350-0a662bfb7e057b0d5302a78687387543836c8c32.tar.bz2 scummvm-rg350-0a662bfb7e057b0d5302a78687387543836c8c32.zip |
cleanup in ScummEngine::drawStripToScreen; in particular, the code is now more efficient for The Dig, FT and COMI
svn-id: r27980
-rw-r--r-- | engines/scumm/gfx.cpp | 78 | ||||
-rw-r--r-- | engines/scumm/scumm.cpp | 6 |
2 files changed, 49 insertions, 35 deletions
diff --git a/engines/scumm/gfx.cpp b/engines/scumm/gfx.cpp index 31f1ea3937..9306c8eac7 100644 --- a/engines/scumm/gfx.cpp +++ b/engines/scumm/gfx.cpp @@ -544,7 +544,6 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i assert(top >= 0 && bottom <= vs->h); assert(x >= 0 && width <= vs->pitch); assert(_textSurface.pixels); - assert(_compositeBuf); // Perform some clipping if (width > vs->w - x) @@ -561,17 +560,26 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i if (width <= 0) return; - // Compute screen etc. buffer pointers const byte *src = vs->getPixels(x, top); - byte *dst = _compositeBuf + x + y * _screenWidth; - if (_game.version < 7) { - // Handle the text mask in older games; newer (V7/V8) games do not use it anymore. + if (_game.version >= 7) { + // For The Dig, FT and COMI, we just blit everything to the screen at once. + _system->copyRectToScreen(src, vs->pitch, x, y, width, height); + + } else { + // For older games, things are more complicated. First off, we need to + // deal with the _textSurface, which needs to be composited over the + // screen contents. Secondly, a rendering mode might be active, which + // means a filter has to be applied. + + // Compute pointers to the composite buffer and the text surface + assert(_compositeBuf); + byte *dst = _compositeBuf + x + y * _screenWidth; const byte *text = (byte *)_textSurface.getBasePtr(x, y); - + #ifdef __DS__ DS::asmDrawStripToScreen(height, width, text, src, dst, vs->pitch, _screenWidth, _textSurface.pitch); -#else +#else // Compose the text over the game graphics for (int h = 0; h < height; ++h) { for (int w = 0; w < width; ++w) { @@ -585,36 +593,38 @@ void ScummEngine::drawStripToScreen(VirtScreen *vs, int x, int width, int top, i text += _textSurface.pitch; } #endif - } else { - // Just do a simple blit in V7/V8 games. - blit(dst, _screenWidth, src, vs->pitch, width, height); - } - if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) { - ditherHerc(_compositeBuf + x + y * _screenWidth, _herculesBuf, _screenWidth, &x, &y, &width, &height); - // center image on the screen - _system->copyRectToScreen(_herculesBuf + x + y * Common::kHercW, Common::kHercW, - x + (Common::kHercW - _screenWidth * 2) / 2, y, width, height); - } else { - if (_renderMode == Common::kRenderCGA) - ditherCGA(_compositeBuf + x + y * _screenWidth, _screenWidth, x, y, width, height); - - // Finally blit the whole thing to the screen - int x1 = x; - - // HACK: This is dirty hack which renders narrow NES rooms centered - // NES can address negative number strips and that poses problem for - // our code. So instead of adding zillions of fixes and potentially - // breaking other games, we shift it right at the rendering stage. - if ((_game.platform == Common::kPlatformNES) && (((_NESStartStrip > 0) && (vs->number == kMainVirtScreen)) || (vs->number == kTextVirtScreen))) { - x += 16; - while (x + width >= _screenWidth) - width -= 16; - if (width < 0) - return; + src = dst = _compositeBuf + x + y * _screenWidth; + int pitch = _screenWidth; + + if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) { + ditherHerc(dst, _herculesBuf, _screenWidth, &x, &y, &width, &height); + + src = _herculesBuf + x + y * Common::kHercW; + pitch = Common::kHercW; + + // center image on the screen + x += (Common::kHercW - _screenWidth * 2) / 2; // (720 - 320*2)/2 = 40 + } else { + if (_renderMode == Common::kRenderCGA) + ditherCGA(dst, _screenWidth, x, y, width, height); + + // HACK: This is dirty hack which renders narrow NES rooms centered + // NES can address negative number strips and that poses problem for + // our code. So instead of adding zillions of fixes and potentially + // breaking other games, we shift it right at the rendering stage. + if ((_game.platform == Common::kPlatformNES) && (((_NESStartStrip > 0) && (vs->number == kMainVirtScreen)) || (vs->number == kTextVirtScreen))) { + x += 16; + while (x + width >= _screenWidth) + width -= 16; + if (width < 0) + return; + } + } - _system->copyRectToScreen(_compositeBuf + x1 + y * _screenWidth, _screenWidth, x, y, width, height); + // Finally blit the whole thing to the screen + _system->copyRectToScreen(src, pitch, x, y, width, height); } } diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 3024f7d900..f29f1c7970 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -521,7 +521,11 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) _screenHeight = 200; } - _compositeBuf = (byte *)malloc(_screenWidth * _screenHeight); + // Allocate gfx compositing buffer (not needed for V7/V8 games). + if (_game.version < 7) + _compositeBuf = (byte *)malloc(_screenWidth * _screenHeight); + else + _compositeBuf = 0; _herculesBuf = 0; if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) { |