Skip to content

Commit

Permalink
SCI32: Fix kShowStyleNone transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
csnover committed Sep 30, 2016
1 parent 21ffb62 commit 63345b2
Showing 1 changed file with 81 additions and 75 deletions.
156 changes: 81 additions & 75 deletions engines/sci/graphics/transitions32.cpp
Expand Up @@ -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<reg_t> *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<reg_t> *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;
}
}

Expand Down

0 comments on commit 63345b2

Please sign in to comment.