aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYotam Barnoy2010-09-02 10:41:26 +0000
committerYotam Barnoy2010-09-02 10:41:26 +0000
commitfd23ab2e17da6f74efdc94ed1b19ec4dd81da558 (patch)
treea92fe1cea49286eb10b8cfa58d16cab172a5e990
parent82f138b728229291d6aa4c6daf2ed916054667c6 (diff)
downloadscummvm-rg350-fd23ab2e17da6f74efdc94ed1b19ec4dd81da558.tar.gz
scummvm-rg350-fd23ab2e17da6f74efdc94ed1b19ec4dd81da558.tar.bz2
scummvm-rg350-fd23ab2e17da6f74efdc94ed1b19ec4dd81da558.zip
FMTOWNS AUDIO: fixed divide by zero exception from commit 52013
Also removed 1 or 2 float operations. svn-id: r52492
-rw-r--r--sound/softsynth/fmtowns_pc98/towns_audio.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/sound/softsynth/fmtowns_pc98/towns_audio.cpp b/sound/softsynth/fmtowns_pc98/towns_audio.cpp
index 5c0961b8c3..5e1ac0201f 100644
--- a/sound/softsynth/fmtowns_pc98/towns_audio.cpp
+++ b/sound/softsynth/fmtowns_pc98/towns_audio.cpp
@@ -1404,8 +1404,11 @@ void TownsAudioInterface::updateOutputVolume() {
// balance values for our -128 to 127 volume range
// CD-AUDIO
- int volume = (int)(((float)MAX(_outputLevel[12], _outputLevel[13]) * 255.0f) / 63.0f);
- int balance = (int)((float)((_outputLevel[13] - _outputLevel[12]) * 127.0f) / (float)MAX(_outputLevel[12], _outputLevel[13]));
+ uint32 maxVol = MAX(_outputLevel[12], _outputLevel[13]);
+
+ int volume = (int)(maxVol * (255.0f / 63.0f));
+ int balance = maxVol ? (int)( ( ((int)_outputLevel[13] - _outputLevel[12]) * 127) / (float)maxVol) : 0;
+
AudioCD.setVolume(volume);
AudioCD.setBalance(balance);
}