diff options
author | Johannes Schickel | 2013-07-18 09:17:23 -0700 |
---|---|---|
committer | Johannes Schickel | 2013-07-18 09:17:23 -0700 |
commit | 325f60cbd732b5a3d4e932063d764009ef7f8121 (patch) | |
tree | ae4ce84ec5c104de8ec5d2591fd9f9fea361a4b2 /engines/scumm | |
parent | 2c812ade01714351aeda3dbbe877d376ad3d48ca (diff) | |
parent | 96c4ebe77fff9f23e085bb80a4907e6f857a96c2 (diff) | |
download | scummvm-rg350-325f60cbd732b5a3d4e932063d764009ef7f8121.tar.gz scummvm-rg350-325f60cbd732b5a3d4e932063d764009ef7f8121.tar.bz2 scummvm-rg350-325f60cbd732b5a3d4e932063d764009ef7f8121.zip |
Merge pull request #345 from countingpine/patch-1
SCUMM: More precise Player_Mac::durationToSamples
Diffstat (limited to 'engines/scumm')
-rw-r--r-- | engines/scumm/player_mac.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/engines/scumm/player_mac.cpp b/engines/scumm/player_mac.cpp index c16c85bff3..a60736df5e 100644 --- a/engines/scumm/player_mac.cpp +++ b/engines/scumm/player_mac.cpp @@ -289,12 +289,16 @@ uint32 Player_Mac::durationToSamples(uint16 duration) { // (duration * 473 * _sampleRate) / (4 * 480 * 480) // // But that's likely to cause integer overflow, so we do it in two - // steps and hope that the rounding error won't be noticeable. + // steps using bitwise operations to perform + // ((duration * 473 * _sampleRate) / 4096) without overflowing, + // then divide this by 225 + // (note that 4 * 480 * 480 == 225 * 4096 == 225 << 12) // // The original code is a bit unclear on if it should be 473 or 437, // but since the comments indicated 473 I'm assuming 437 was a typo. - uint32 samples = (duration * _sampleRate) / (4 * 480); - samples = (samples * 473) / 480; + uint32 samples = (duration * _sampleRate); + samples = (samples >> 12) * 473 + (((samples & 4095) * 473) >> 12); + samples = samples / 225; return samples; } |