Browse Source
Fixes big-endian tests, which currently build with `-DNOSOUND` to reduce build time.pull/5592/head
8 changed files with 40 additions and 21 deletions
@ -0,0 +1,27 @@
|
||||
#include "engine/sound_position.hpp" |
||||
|
||||
#include "engine/sound_defs.hpp" |
||||
#include "player.h" |
||||
|
||||
namespace devilution { |
||||
|
||||
bool CalculateSoundPosition(Point soundPosition, int *plVolume, int *plPan) |
||||
{ |
||||
const auto &playerPosition = MyPlayer->position.tile; |
||||
const auto delta = soundPosition - playerPosition; |
||||
|
||||
int pan = (delta.deltaX - delta.deltaY) * 256; |
||||
*plPan = clamp(pan, PAN_MIN, PAN_MAX); |
||||
|
||||
int volume = playerPosition.ApproxDistance(soundPosition); |
||||
volume *= -64; |
||||
|
||||
if (volume <= ATTENUATION_MIN) |
||||
return false; |
||||
|
||||
*plVolume = volume; |
||||
|
||||
return true; |
||||
} |
||||
|
||||
} // namespace devilution
|
||||
@ -0,0 +1,9 @@
|
||||
#pragma once |
||||
|
||||
#include "engine/point.hpp" |
||||
|
||||
namespace devilution { |
||||
|
||||
bool CalculateSoundPosition(Point soundPosition, int *plVolume, int *plPan); |
||||
|
||||
} // namespace devilution
|
||||
Loading…
Reference in new issue