diff options
author | Bendegúz Nagy | 2016-06-29 23:02:34 +0200 |
---|---|---|
committer | Bendegúz Nagy | 2016-08-26 23:02:22 +0200 |
commit | 3f19bcdf6b47bc7227eb91c6eb95fb20335276f6 (patch) | |
tree | d61ea2b353d2ab531ba618b78c924a2a98e0b05c | |
parent | 36a29bbe867206d2b0b408550ad4ee15610c9276 (diff) | |
download | scummvm-rg350-3f19bcdf6b47bc7227eb91c6eb95fb20335276f6.tar.gz scummvm-rg350-3f19bcdf6b47bc7227eb91c6eb95fb20335276f6.tar.bz2 scummvm-rg350-3f19bcdf6b47bc7227eb91c6eb95fb20335276f6.zip |
DM: Add F0491_CACHE_IsDerivedBitmapInCache, F0492_CACHE_GetDerivedBitmap
-rw-r--r-- | engines/dm/gfx.cpp | 33 | ||||
-rw-r--r-- | engines/dm/gfx.h | 3 |
2 files changed, 31 insertions, 5 deletions
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index 0c55fe557e..ea3a4b7b67 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -617,6 +617,7 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) { _ceilingBitmap = nullptr; _currMapAllowedCreatureTypes = nullptr; _derivedBitmapByteCount = nullptr; + _derivedBitmaps = nullptr; _screenWidth = _screenHeight = 0; _championPortraitOrdinal = 0; @@ -671,6 +672,13 @@ DisplayMan::~DisplayMan() { delete[] _wallSetBitMaps[kDoorFrameRight_D1C]; // copy of another bitmap, but flipped for (uint16 i = kWall_D0L_Flipped; i <= kWall_D3LCR_Flipped; ++i) delete[] _wallSetBitMaps[i]; + + delete[] _derivedBitmapByteCount; + if (_derivedBitmaps) { + for (uint16 i = 0; i < kDerivedBitmapMaximumCount; ++i) + delete[] _derivedBitmaps; + delete[] _derivedBitmaps; + } } void DisplayMan::setUpScreens(uint16 width, uint16 height) { @@ -712,6 +720,11 @@ void DisplayMan::loadGraphics() { if (!_derivedBitmapByteCount) _derivedBitmapByteCount = new uint16[kDerivedBitmapMaximumCount]; + if (!_derivedBitmaps) { + _derivedBitmaps = new byte*[kDerivedBitmapMaximumCount]; + for (uint16 i = 0; i < kDerivedBitmapMaximumCount; ++i) + _derivedBitmaps[i] = nullptr; + } _derivedBitmapByteCount[kDerivedBitmapViewport] = 224 * 136; _derivedBitmapByteCount[kDerivedBitmapThievesEyeVisibleArea] = 96 * 95; @@ -791,16 +804,16 @@ void DisplayMan::loadGraphics() { CreatureAspect *creatureAsp; for (int16 creatureIndex = 0; creatureIndex < kCreatureTypeCount; creatureIndex++) { creatureAsp = &gCreatureAspects[creatureIndex]; - + int16 creatureGraphicInfo = gCreatureInfo[creatureIndex]._graphicInfo; creatureAsp->_firstDerivedBitmapIndex = derivedBitmapIndex; - + int16 creatureFrontBitmapD3PixelCount; _derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale16_D3); - + int16 creatureFrontBitmapD2PixelCount; _derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale20_D2); - + if (getFlag(creatureGraphicInfo, kCreatureInfoMaskSide)) { _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, kScale16_D3); _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, kScale20_D2); @@ -1719,6 +1732,18 @@ int16 DisplayMan::getScaledDimension(int16 dimension, int16 scale) { return (dimension * scale + scale / 2) / 32; } +bool DisplayMan::isDerivedBitmapInCache(int16 derivedBitmapIndex) { + if (_derivedBitmaps == nullptr) { + _derivedBitmaps[derivedBitmapIndex] = new byte[_derivedBitmapByteCount[derivedBitmapIndex]]; + return false; + } else + return true; +} + +byte* DisplayMan::getDerivedBitmap(int16 derivedBitmapIndex) { + return _derivedBitmaps[derivedBitmapIndex]; +} + void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) { uint16 width = box._x2 - box._x1; for (int y = box._y1 + viewport._posY; y < box._y2 + viewport._posY; ++y) diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 0e7bcf65ec..ba6584f0f4 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -390,7 +390,8 @@ class DisplayMan { bool isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex); // @ F0107_DUNGEONVIEW_IsDrawnWallOrnamentAnAlcove_CPSF - uint16 *_derivedBitmapByteCount;// @ G0639_pui_DerivedBitmapByteCount + uint16 *_derivedBitmapByteCount; // @ G0639_pui_DerivedBitmapByteCount + byte **_derivedBitmaps; // @ G0638_pui_DerivedBitmapBlockIndices public: // some methods use this for a stratchpad, don't make assumptions about content between function calls |