From 2597e69f29a4b603cbfc7d53d034a2a9d3405de4 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Sat, 22 Jul 2017 16:28:53 +0200 Subject: MOHAWK: Myst: Fix Selenitic sound receiver buttons not flashing The new screen update strategy does not allow scripts to draw twice at the same location for blinking. --- engines/mohawk/myst_stacks/selenitic.cpp | 23 +++++++++++++++++++---- engines/mohawk/myst_stacks/selenitic.h | 1 + 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'engines/mohawk') diff --git a/engines/mohawk/myst_stacks/selenitic.cpp b/engines/mohawk/myst_stacks/selenitic.cpp index 087143abfc..e9439047ff 100644 --- a/engines/mohawk/myst_stacks/selenitic.cpp +++ b/engines/mohawk/myst_stacks/selenitic.cpp @@ -44,6 +44,7 @@ Selenitic::Selenitic(MohawkEngine_Myst *vm) : _soundReceiverDirection = 0; _soundReceiverStartTime = 0; + _soundReceiverNearBlinkCounter = 0; } Selenitic::~Selenitic() { @@ -990,13 +991,26 @@ uint16 Selenitic::soundReceiverCurrentSound(uint16 source, uint16 position) { if (position == solution) { soundId = soundIdGood; } else if (position > solution && position <= solution + 50) { - _soundReceiverLeftButton->drawConditionalDataToScreen(2); - _soundReceiverLeftButton->drawConditionalDataToScreen(0); + _soundReceiverNearBlinkCounter++; + if (_soundReceiverNearBlinkCounter % 2) { + _soundReceiverLeftButton->drawConditionalDataToScreen(2); + } else { + _soundReceiverLeftButton->drawConditionalDataToScreen(0); + } soundId = soundIdNear; } else if (position < solution && position >= solution - 50) { - _soundReceiverRightButton->drawConditionalDataToScreen(2); - _soundReceiverRightButton->drawConditionalDataToScreen(0); + _soundReceiverNearBlinkCounter++; + if (_soundReceiverNearBlinkCounter % 2) { + _soundReceiverRightButton->drawConditionalDataToScreen(2); + } else { + _soundReceiverRightButton->drawConditionalDataToScreen(0); + } soundId = soundIdNear; + } else if (_soundReceiverNearBlinkCounter > 0) { + // Make sure the buttons don't stay highlighted when leaving the 'near' area + _soundReceiverRightButton->drawConditionalDataToScreen(0); + _soundReceiverLeftButton->drawConditionalDataToScreen(0); + _soundReceiverNearBlinkCounter = 0; } } @@ -1053,6 +1067,7 @@ void Selenitic::o_soundReceiver_init(uint16 var, const ArgumentsArray &args) { soundReceiverSetSubimageRect(); _soundReceiverSigmaPressed = false; + _soundReceiverNearBlinkCounter = 0; } void Selenitic::o_soundLock_init(uint16 var, const ArgumentsArray &args) { diff --git a/engines/mohawk/myst_stacks/selenitic.h b/engines/mohawk/myst_stacks/selenitic.h index e0b4564bb9..341886d20b 100644 --- a/engines/mohawk/myst_stacks/selenitic.h +++ b/engines/mohawk/myst_stacks/selenitic.h @@ -86,6 +86,7 @@ private: uint16 _soundReceiverDirection; // 120 uint16 _soundReceiverSpeed; // 122 uint32 _soundReceiverStartTime; //124 + uint _soundReceiverNearBlinkCounter; MystAreaImageSwitch *_soundReceiverViewer; // 128 MystAreaImageSwitch *_soundReceiverRightButton; // 132 MystAreaImageSwitch *_soundReceiverLeftButton; // 136 -- cgit v1.2.3