Пример #1
0
void GfxPalette32::doCycle(const uint8 fromColor, const int16 speed) {
	PalCycler *const cycler = getCycler(fromColor);
	if (cycler != nullptr) {
		cycler->lastUpdateTick = g_sci->getTickCount();
		updateCycler(*cycler, speed);
	}
}
Пример #2
0
void GfxPalette32::setCycle(const uint8 fromColor, const uint8 toColor, const int16 direction, const int16 delay) {
	assert(fromColor < toColor);

	PalCycler *cycler = getCycler(fromColor);

	if (cycler != nullptr) {
		clearCycleMap(fromColor, cycler->numColorsToCycle);
	} else {
		for (int i = 0; i < kNumCyclers; ++i) {
			if (!_cyclers[i]) {
				cycler = new PalCycler;
				_cyclers[i].reset(cycler);
				break;
			}
		}
	}

	// If there are no free cycler slots, SSCI overrides the first oldest cycler
	// that it finds, where "oldest" is determined by the difference between the
	// tick and now
	if (cycler == nullptr) {
		const uint32 now = g_sci->getTickCount();
		uint32 minUpdateDelta = 0xFFFFFFFF;

		for (int i = 0; i < kNumCyclers; ++i) {
			PalCyclerOwner &candidate = _cyclers[i];

			const uint32 updateDelta = now - candidate->lastUpdateTick;
			if (updateDelta < minUpdateDelta) {
				minUpdateDelta = updateDelta;
				cycler = candidate.get();
			}
		}

		clearCycleMap(cycler->fromColor, cycler->numColorsToCycle);
	}

	uint16 numColorsToCycle = toColor - fromColor;
	if (g_sci->_features->hasMidPaletteCode()) {
		numColorsToCycle += 1;
	}
	cycler->fromColor = fromColor;
	cycler->numColorsToCycle = numColorsToCycle;
	cycler->currentCycle = fromColor;
	cycler->direction = direction < 0 ? kPalCycleBackward : kPalCycleForward;
	cycler->delay = delay;
	cycler->lastUpdateTick = g_sci->getTickCount();
	cycler->numTimesPaused = 0;

	setCycleMap(fromColor, numColorsToCycle);
}
Пример #3
0
void GfxPalette32::setCycle(const uint8 fromColor, const uint8 toColor, const int16 direction, const int16 delay) {
    assert(fromColor < toColor);

    PalCycler *cycler = getCycler(fromColor);

    if (cycler != nullptr) {
        clearCycleMap(fromColor, cycler->numColorsToCycle);
    } else {
        for (int i = 0; i < kNumCyclers; ++i) {
            if (_cyclers[i] == nullptr) {
                _cyclers[i] = cycler = new PalCycler;
                break;
            }
        }
    }

    // If there are no free cycler slots, SCI engine overrides the first oldest
    // cycler that it finds, where "oldest" is determined by the difference
    // between the tick and now
    if (cycler == nullptr) {
        const uint32 now = g_sci->getTickCount();
        uint32 minUpdateDelta = 0xFFFFFFFF;

        for (int i = 0; i < kNumCyclers; ++i) {
            PalCycler *const candidate = _cyclers[i];

            const uint32 updateDelta = now - candidate->lastUpdateTick;
            if (updateDelta < minUpdateDelta) {
                minUpdateDelta = updateDelta;
                cycler = candidate;
            }
        }

        clearCycleMap(cycler->fromColor, cycler->numColorsToCycle);
    }

    uint16 numColorsToCycle = toColor - fromColor;
    if (getSciVersion() >= SCI_VERSION_2_1_MIDDLE || g_sci->getGameId() == GID_KQ7) {
        numColorsToCycle += 1;
    }
    cycler->fromColor = fromColor;
    cycler->numColorsToCycle = numColorsToCycle;
    cycler->currentCycle = fromColor;
    cycler->direction = direction < 0 ? kPalCycleBackward : kPalCycleForward;
    cycler->delay = delay;
    cycler->lastUpdateTick = g_sci->getTickCount();
    cycler->numTimesPaused = 0;

    setCycleMap(fromColor, numColorsToCycle);
}
Пример #4
0
void GfxPalette32::cyclePause(const uint8 fromColor) {
	PalCycler *const cycler = getCycler(fromColor);
	if (cycler != nullptr) {
		++cycler->numTimesPaused;
	}
}
Пример #5
0
void GfxPalette32::cycleOn(const uint8 fromColor) {
	PalCycler *const cycler = getCycler(fromColor);
	if (cycler != nullptr && cycler->numTimesPaused > 0) {
		--cycler->numTimesPaused;
	}
}