DM: Add F0491_CACHE_IsDerivedBitmapInCache, F0492_CACHE_GetDerivedBitmap

This commit is contained in:
Bendegúz Nagy 2016-06-29 23:02:34 +02:00
parent 36a29bbe86
commit 3f19bcdf6b
2 changed files with 31 additions and 5 deletions

View file

@ -617,6 +617,7 @@ DisplayMan::DisplayMan(DMEngine *dmEngine) : _vm(dmEngine) {
_ceilingBitmap = nullptr; _ceilingBitmap = nullptr;
_currMapAllowedCreatureTypes = nullptr; _currMapAllowedCreatureTypes = nullptr;
_derivedBitmapByteCount = nullptr; _derivedBitmapByteCount = nullptr;
_derivedBitmaps = nullptr;
_screenWidth = _screenHeight = 0; _screenWidth = _screenHeight = 0;
_championPortraitOrdinal = 0; _championPortraitOrdinal = 0;
@ -671,6 +672,13 @@ DisplayMan::~DisplayMan() {
delete[] _wallSetBitMaps[kDoorFrameRight_D1C]; // copy of another bitmap, but flipped delete[] _wallSetBitMaps[kDoorFrameRight_D1C]; // copy of another bitmap, but flipped
for (uint16 i = kWall_D0L_Flipped; i <= kWall_D3LCR_Flipped; ++i) for (uint16 i = kWall_D0L_Flipped; i <= kWall_D3LCR_Flipped; ++i)
delete[] _wallSetBitMaps[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) { void DisplayMan::setUpScreens(uint16 width, uint16 height) {
@ -712,6 +720,11 @@ void DisplayMan::loadGraphics() {
if (!_derivedBitmapByteCount) if (!_derivedBitmapByteCount)
_derivedBitmapByteCount = new uint16[kDerivedBitmapMaximumCount]; _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[kDerivedBitmapViewport] = 224 * 136;
_derivedBitmapByteCount[kDerivedBitmapThievesEyeVisibleArea] = 96 * 95; _derivedBitmapByteCount[kDerivedBitmapThievesEyeVisibleArea] = 96 * 95;
@ -791,16 +804,16 @@ void DisplayMan::loadGraphics() {
CreatureAspect *creatureAsp; CreatureAspect *creatureAsp;
for (int16 creatureIndex = 0; creatureIndex < kCreatureTypeCount; creatureIndex++) { for (int16 creatureIndex = 0; creatureIndex < kCreatureTypeCount; creatureIndex++) {
creatureAsp = &gCreatureAspects[creatureIndex]; creatureAsp = &gCreatureAspects[creatureIndex];
int16 creatureGraphicInfo = gCreatureInfo[creatureIndex]._graphicInfo; int16 creatureGraphicInfo = gCreatureInfo[creatureIndex]._graphicInfo;
creatureAsp->_firstDerivedBitmapIndex = derivedBitmapIndex; creatureAsp->_firstDerivedBitmapIndex = derivedBitmapIndex;
int16 creatureFrontBitmapD3PixelCount; int16 creatureFrontBitmapD3PixelCount;
_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale16_D3); _derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD3PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale16_D3);
int16 creatureFrontBitmapD2PixelCount; int16 creatureFrontBitmapD2PixelCount;
_derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale20_D2); _derivedBitmapByteCount[derivedBitmapIndex++] = creatureFrontBitmapD2PixelCount = getScaledBitmapPixelCount(creatureAsp->_byteWidthFront, creatureAsp->_heightFront, kScale20_D2);
if (getFlag(creatureGraphicInfo, kCreatureInfoMaskSide)) { if (getFlag(creatureGraphicInfo, kCreatureInfoMaskSide)) {
_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, kScale16_D3); _derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, kScale16_D3);
_derivedBitmapByteCount[derivedBitmapIndex++] = getScaledBitmapPixelCount(creatureAsp->_byteWidthSide, creatureAsp->_heightSide, kScale20_D2); _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; 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) { void DisplayMan::clearScreenBox(Color color, Box &box, Viewport &viewport) {
uint16 width = box._x2 - box._x1; uint16 width = box._x2 - box._x1;
for (int y = box._y1 + viewport._posY; y < box._y2 + viewport._posY; ++y) for (int y = box._y1 + viewport._posY; y < box._y2 + viewport._posY; ++y)

View file

@ -390,7 +390,8 @@ class DisplayMan {
bool isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex); // @ F0107_DUNGEONVIEW_IsDrawnWallOrnamentAnAlcove_CPSF 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: public:
// some methods use this for a stratchpad, don't make assumptions about content between function calls // some methods use this for a stratchpad, don't make assumptions about content between function calls