SHERLOCK: Make random pixel transitions more like the original

This commit is contained in:
Paul Gilbert 2015-03-18 19:02:17 -04:00
parent 62f3f5d14e
commit b8ad1ce140
3 changed files with 37 additions and 13 deletions

View File

@ -166,18 +166,32 @@ void EventsManager::wait(int numFrames) {
}
bool EventsManager::delay(uint32 time, bool interruptable) {
uint32 delayEnd = g_system->getMillis() + time;
// Different handling for really short versus extended times
if (time < 10) {
// For really short periods, simply delay by the desired amount
pollEvents();
g_system->delayMillis(time);
bool result = !(interruptable && (isKeyPressed() || _mouseClicked));
while (!_vm->shouldQuit() && g_system->getMillis() < delayEnd) {
pollEventsAndWait();
clearEvents();
return result;
} else {
// For long periods go into a loop where we delay by 10ms at a time and then
// check for events. This ensures for longer delays that responsiveness is
// maintained
uint32 delayEnd = g_system->getMillis() + time;
if (interruptable && (isKeyPressed() || _mouseClicked)) {
clearEvents();
return false;
while (!_vm->shouldQuit() && g_system->getMillis() < delayEnd) {
pollEventsAndWait();
if (interruptable && (isKeyPressed() || _mouseClicked)) {
clearEvents();
return false;
}
}
}
return true;
return true;
}
}
/**

View File

@ -30,6 +30,7 @@ namespace Sherlock {
Screen::Screen(SherlockEngine *vm) : Surface(SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT), _vm(vm),
_backBuffer(SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT),
_backBuffer2(SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT) {
_transitionSeed = 1;
setFont(1);
}
@ -178,15 +179,23 @@ bool Screen::unionRectangle(Common::Rect &destRect, const Common::Rect &src1, co
*/
void Screen::randomTransition() {
EventsManager &events = *_vm->_events;
const int TRANSITION_MULTIPLIER = 0x15a4e35;
_dirtyRects.clear();
for (int idx = 0; idx <= 65535; ++idx) {
int offset = _vm->getRandomNumber(this->w * this->h);
*((byte *)getPixels() + offset) = *((const byte *)_backBuffer.getPixels() + offset);
_transitionSeed = _transitionSeed * TRANSITION_MULTIPLIER + 1;
int offset = _transitionSeed & 65535;
if (offset < (SHERLOCK_SCREEN_WIDTH * SHERLOCK_SCREEN_HEIGHT))
*((byte *)getPixels() + offset) = *((const byte *)_backBuffer.getPixels() + offset);
if (idx != 0 && (idx % 100) == 0) {
_dirtyRects.clear();
addDirtyRect(Common::Rect(0, 0, this->w, this->h));
events.delay(5);
// Ensure there's a full screen dirty rect for the next frame update
if (_dirtyRects.empty())
addDirtyRect(Common::Rect(0, 0, this->w, this->h));
events.pollEvents();
events.delay(1);
}
}

View File

@ -42,6 +42,7 @@ private:
SherlockEngine *_vm;
int _fontNumber;
Common::List<Common::Rect> _dirtyRects;
uint32 _transitionSeed;
void mergeDirtyRects();