From 2b02a04114c63dbc51a3994abd2b0aa405bfb7cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Wed, 11 Nov 2015 08:05:52 +0100 Subject: [PATCH 1/2] Use C++'s std::abs instead of C's to get floats C's abs() will only work on int values, only std::abs will get floats. --- src/audio/mixer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/audio/mixer.cpp b/src/audio/mixer.cpp index fa692f1787..d8c4bcfb19 100644 --- a/src/audio/mixer.cpp +++ b/src/audio/mixer.cpp @@ -26,6 +26,7 @@ extern "C" { #include "audio.h" } #include "mixer.h" +#include Mixer gMixer; @@ -393,7 +394,7 @@ void Channel::SetPan(float pan) if (pan < 0) { Channel::pan = 0; } - double decibels = (abs(Channel::pan - 0.5) * 2.0) * 100.0; + double decibels = (std::abs(Channel::pan - 0.5) * 2.0) * 100.0; double attenuation = pow(10, decibels / 20.0); if (Channel::pan <= 0.5) { volume_l = 1.0; From 74cc03ac06e0d0ff576d7a1b6f6bdf76714bd02c Mon Sep 17 00:00:00 2001 From: Alexander Overvoorde Date: Wed, 11 Nov 2015 15:17:43 +0100 Subject: [PATCH 2/2] Fix title sequence script interpreter treating parameters as commands (fixes #2284) --- src/title.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/title.c b/src/title.c index 56bb9e1265..1b8abc325a 100644 --- a/src/title.c +++ b/src/title.c @@ -80,6 +80,7 @@ static const uint8 _magicMountainScript[] = { static uint8* _loadedScript; static const uint8* _currentScript; +static uint8 _lastOpcode; static int _scriptNoLoadsSinceRestart; static int _scriptWaitCounter; static int _scriptCurrentPreset; @@ -264,6 +265,8 @@ static void title_skip_opcode() script_opcode = *_currentScript++; gTitleScriptCommand++; + _lastOpcode = script_opcode; + switch (script_opcode) { case TITLE_SCRIPT_WAIT: _currentScript++; @@ -314,6 +317,9 @@ static void title_do_next_script_opcode() return; } } + + _lastOpcode = script_opcode; + switch (script_opcode) { case TITLE_SCRIPT_END: _scriptWaitCounter = 1; @@ -439,7 +445,7 @@ static void title_update_showcase() if (gTitleScriptSkipTo != -1 && gTitleScriptSkipLoad != -1) _scriptWaitCounter = 0; - else if (*(_currentScript - 1) != TITLE_SCRIPT_END) + else if (_lastOpcode != TITLE_SCRIPT_END) _scriptWaitCounter--; } while (gTitleScriptSkipTo != -1 && gTitleScriptSkipLoad != -1);