diff options
author | MerryMage <MerryMage@users.noreply.github.com> | 2016-04-25 11:01:37 +0200 |
---|---|---|
committer | MerryMage <MerryMage@users.noreply.github.com> | 2016-04-29 17:32:29 +0200 |
commit | 22995bd9bfc5e7f103e03066d4aa035e4294c359 (patch) | |
tree | 7610b942422a12796f6cfacbaf287fdbf61b4b6b /src/audio_core/hle/dsp.cpp | |
parent | Merge pull request #1708 from MerryMage/dsp_dsp (diff) | |
download | yuzu-22995bd9bfc5e7f103e03066d4aa035e4294c359.tar yuzu-22995bd9bfc5e7f103e03066d4aa035e4294c359.tar.gz yuzu-22995bd9bfc5e7f103e03066d4aa035e4294c359.tar.bz2 yuzu-22995bd9bfc5e7f103e03066d4aa035e4294c359.tar.lz yuzu-22995bd9bfc5e7f103e03066d4aa035e4294c359.tar.xz yuzu-22995bd9bfc5e7f103e03066d4aa035e4294c359.tar.zst yuzu-22995bd9bfc5e7f103e03066d4aa035e4294c359.zip |
Diffstat (limited to 'src/audio_core/hle/dsp.cpp')
-rw-r--r-- | src/audio_core/hle/dsp.cpp | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/src/audio_core/hle/dsp.cpp b/src/audio_core/hle/dsp.cpp index c89356edc..5759a5b9e 100644 --- a/src/audio_core/hle/dsp.cpp +++ b/src/audio_core/hle/dsp.cpp @@ -8,8 +8,32 @@ namespace DSP { namespace HLE { -SharedMemory g_region0; -SharedMemory g_region1; +std::array<SharedMemory, 2> g_regions; + +static size_t CurrentRegionIndex() { + // The region with the higher frame counter is chosen unless there is wraparound. + // This function only returns a 0 or 1. + + if (g_regions[0].frame_counter == 0xFFFFu && g_regions[1].frame_counter != 0xFFFEu) { + // Wraparound has occured. + return 1; + } + + if (g_regions[1].frame_counter == 0xFFFFu && g_regions[0].frame_counter != 0xFFFEu) { + // Wraparound has occured. + return 0; + } + + return (g_regions[0].frame_counter > g_regions[1].frame_counter) ? 0 : 1; +} + +static SharedMemory& ReadRegion() { + return g_regions[CurrentRegionIndex()]; +} + +static SharedMemory& WriteRegion() { + return g_regions[1 - CurrentRegionIndex()]; +} void Init() { DSP::HLE::ResetPipes(); @@ -22,21 +46,5 @@ bool Tick() { return true; } -SharedMemory& CurrentRegion() { - // The region with the higher frame counter is chosen unless there is wraparound. - - if (g_region0.frame_counter == 0xFFFFu && g_region1.frame_counter != 0xFFFEu) { - // Wraparound has occured. - return g_region1; - } - - if (g_region1.frame_counter == 0xFFFFu && g_region0.frame_counter != 0xFFFEu) { - // Wraparound has occured. - return g_region0; - } - - return (g_region0.frame_counter > g_region1.frame_counter) ? g_region0 : g_region1; -} - } // namespace HLE } // namespace DSP |