From 63345b2b70e72330b4f2845bd45e13117be41dc4 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Fri, 26 Aug 2016 19:49:31 -0500 Subject: SCI32: Fix kShowStyleNone transitions --- engines/sci/graphics/transitions32.cpp | 156 +++++++++++++++++---------------- 1 file changed, 81 insertions(+), 75 deletions(-) (limited to 'engines/sci/graphics/transitions32.cpp') diff --git a/engines/sci/graphics/transitions32.cpp b/engines/sci/graphics/transitions32.cpp index 361c38e2b4..e98f783922 100644 --- a/engines/sci/graphics/transitions32.cpp +++ b/engines/sci/graphics/transitions32.cpp @@ -233,92 +233,98 @@ void GfxTransitions32::kernelSetShowStyle(const uint16 argc, const reg_t planeOb } } - if (type > 0) { - if (createNewEntry) { - entry = new PlaneShowStyle; - // NOTE: SCI2.1 engine tests if allocation returned a null pointer - // but then only avoids setting currentStep if this is so. Since - // this is a nonsensical approach, we do not do that here - entry->currentStep = 0; - entry->processed = false; - entry->divisions = hasDivisions ? divisions : _defaultDivisions[type]; - entry->plane = planeObj; - entry->fadeColorRangesCount = 0; - - if (getSciVersion() < SCI_VERSION_2_1_MIDDLE) { - // for pixel dissolve - entry->bitmap = NULL_REG; - entry->bitmapScreenItem = nullptr; - - // for wipe - entry->screenItems.clear(); - entry->width = plane->_gameRect.width(); - entry->height = plane->_gameRect.height(); - } else { - entry->fadeColorRanges = nullptr; - if (hasFadeArray) { - // NOTE: SCI2.1mid engine does no check to verify that an array is - // successfully retrieved, and SegMan will cause a fatal error - // if we try to use a memory segment that is not an array - SciArray *table = _segMan->lookupArray(pFadeArray); - - uint32 rangeCount = table->getSize(); - entry->fadeColorRangesCount = rangeCount; - - // NOTE: SCI engine code always allocates memory even if the range - // table has no entries, but this does not really make sense, so - // we avoid the allocation call in this case - if (rangeCount > 0) { - entry->fadeColorRanges = new uint16[rangeCount]; - for (size_t i = 0; i < rangeCount; ++i) { - entry->fadeColorRanges[i] = table->getValue(i).toUint16(); - } + if (type == kShowStyleNone) { + if (createNewEntry == false) { + deleteShowStyle(findIteratorForPlane(planeObj)); + } + + return; + } + + if (createNewEntry) { + entry = new PlaneShowStyle; + // NOTE: SCI2.1 engine tests if allocation returned a null pointer + // but then only avoids setting currentStep if this is so. Since + // this is a nonsensical approach, we do not do that here + entry->currentStep = 0; + entry->processed = false; + entry->divisions = hasDivisions ? divisions : _defaultDivisions[type]; + entry->plane = planeObj; + entry->fadeColorRangesCount = 0; + + if (getSciVersion() < SCI_VERSION_2_1_MIDDLE) { + // for pixel dissolve + entry->bitmap = NULL_REG; + entry->bitmapScreenItem = nullptr; + + // for wipe + entry->screenItems.clear(); + entry->width = plane->_gameRect.width(); + entry->height = plane->_gameRect.height(); + } else { + entry->fadeColorRanges = nullptr; + if (hasFadeArray) { + // NOTE: SCI2.1mid engine does no check to verify that an array is + // successfully retrieved, and SegMan will cause a fatal error + // if we try to use a memory segment that is not an array + SciArray *table = _segMan->lookupArray(pFadeArray); + + uint32 rangeCount = table->getSize(); + entry->fadeColorRangesCount = rangeCount; + + // NOTE: SCI engine code always allocates memory even if the range + // table has no entries, but this does not really make sense, so + // we avoid the allocation call in this case + if (rangeCount > 0) { + entry->fadeColorRanges = new uint16[rangeCount]; + for (size_t i = 0; i < rangeCount; ++i) { + entry->fadeColorRanges[i] = table->getValue(i).toUint16(); } } } } + } - // NOTE: The original engine had no nullptr check and would just crash - // if it got to here - if (entry == nullptr) { - error("Cannot edit non-existing ShowStyle entry"); - } + // NOTE: The original engine had no nullptr check and would just crash + // if it got to here + if (entry == nullptr) { + error("Cannot edit non-existing ShowStyle entry"); + } - entry->fadeUp = isFadeUp; - entry->color = color; - entry->nextTick = g_sci->getTickCount(); - entry->type = type; - entry->animate = animate; - entry->delay = (seconds * 60 + entry->divisions - 1) / entry->divisions; + entry->fadeUp = isFadeUp; + entry->color = color; + entry->nextTick = g_sci->getTickCount(); + entry->type = type; + entry->animate = animate; + entry->delay = (seconds * 60 + entry->divisions - 1) / entry->divisions; - if (entry->delay == 0) { - error("ShowStyle has no duration"); - } + if (entry->delay == 0) { + error("ShowStyle has no duration"); + } - if (frameOutNow) { - // Creates a reference frame for the pixel dissolves to use - g_sci->_gfxFrameout->frameOut(false); - } + if (frameOutNow) { + // Creates a reference frame for the pixel dissolves to use + g_sci->_gfxFrameout->frameOut(false); + } - if (createNewEntry) { - if (getSciVersion() <= SCI_VERSION_2_1_EARLY) { - switch (entry->type) { - case kShowStyleIrisOut: - case kShowStyleIrisIn: - configure21EarlyIris(*entry, priority); - break; - case kShowStyleDissolve: - configure21EarlyDissolve(*entry, priority, plane->_gameRect); - break; - default: - // do nothing - break; - } + if (createNewEntry) { + if (getSciVersion() <= SCI_VERSION_2_1_EARLY) { + switch (entry->type) { + case kShowStyleIrisOut: + case kShowStyleIrisIn: + configure21EarlyIris(*entry, priority); + break; + case kShowStyleDissolve: + configure21EarlyDissolve(*entry, priority, plane->_gameRect); + break; + default: + // do nothing + break; } - - _showStyles.push_back(*entry); - delete entry; } + + _showStyles.push_back(*entry); + delete entry; } } -- cgit v1.2.3