mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-03 12:27:21 +12:00
HLE DSP: Fix format and source type for audio buffers
This commit is contained in:
parent
1c355041fa
commit
1cc3bbf68d
3 changed files with 55 additions and 5 deletions
|
@ -8,6 +8,9 @@
|
|||
#include "memory.hpp"
|
||||
|
||||
namespace Audio {
|
||||
using SampleFormat = HLE::SourceConfiguration::Configuration::Format;
|
||||
using SourceType = HLE::SourceConfiguration::Configuration::MonoOrStereo;
|
||||
|
||||
struct DSPSource {
|
||||
// Audio buffer information
|
||||
// https://www.3dbrew.org/wiki/DSP_Memory_Region
|
||||
|
@ -24,6 +27,9 @@ namespace Audio {
|
|||
u8 pad2;
|
||||
|
||||
u32 playPosition = 0; // Current position in the buffer
|
||||
SampleFormat format;
|
||||
SourceType sourceType;
|
||||
|
||||
bool fromQueue = false; // Is this buffer from the buffer queue or an embedded buffer?
|
||||
bool hasPlayedOnce = false; // Has the buffer been played at least once before?
|
||||
|
||||
|
@ -81,6 +87,9 @@ namespace Audio {
|
|||
std::array<Source, Audio::HLE::sourceCount> sources; // DSP voices
|
||||
Audio::HLE::DspMemory dspRam;
|
||||
|
||||
SampleFormat sampleFormat = SampleFormat::ADPCM;
|
||||
SourceType sourceType = SourceType::Stereo;
|
||||
|
||||
void resetAudioPipe();
|
||||
bool loaded = false; // Have we loaded a component?
|
||||
|
||||
|
@ -104,9 +113,27 @@ namespace Audio {
|
|||
Audio::HLE::SharedMemory& readRegion() { return readRegionIndex() == 0 ? dspRam.region0 : dspRam.region1; }
|
||||
Audio::HLE::SharedMemory& writeRegion() { return readRegionIndex() == 0 ? dspRam.region1 : dspRam.region0; }
|
||||
|
||||
// Get a pointer of type T* to the data starting from physical address paddr
|
||||
template <typename T>
|
||||
T* getPointerPhys(u32 paddr, u32 size = 0) {
|
||||
if (paddr >= PhysicalAddrs::FCRAM && paddr + size <= PhysicalAddrs::FCRAMEnd) {
|
||||
u8* fcram = mem.getFCRAM();
|
||||
u32 index = paddr - PhysicalAddrs::FCRAM;
|
||||
|
||||
return (T*)&fcram[index];
|
||||
} else if (paddr >= PhysicalAddrs::DSP_RAM && paddr + size <= PhysicalAddrs::DSP_RAM_End) {
|
||||
u32 index = paddr - PhysicalAddrs::DSP_RAM;
|
||||
return (T*)&dspRam.rawMemory[index];
|
||||
} else [[unlikely]] {
|
||||
Helpers::warn("[DSP] Tried to access unknown physical address: %08X", paddr);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void updateSourceConfig(Source& source, HLE::SourceConfiguration::Configuration& config);
|
||||
void generateFrame(StereoFrame<s16>& frame);
|
||||
void outputFrame();
|
||||
void dumpBuffer(const Source::Buffer& buffer);
|
||||
public:
|
||||
HLE_DSP(Memory& mem, Scheduler& scheduler, DSPService& dspService);
|
||||
~HLE_DSP() override {}
|
||||
|
|
|
@ -19,7 +19,10 @@ namespace PhysicalAddrs {
|
|||
VRAM = 0x18000000,
|
||||
VRAMEnd = VRAM + 0x005FFFFF,
|
||||
FCRAM = 0x20000000,
|
||||
FCRAMEnd = FCRAM + 0x07FFFFFF
|
||||
FCRAMEnd = FCRAM + 0x07FFFFFF,
|
||||
|
||||
DSP_RAM = 0x1FF00000,
|
||||
DSP_RAM_End = DSP_RAM + 0x0007FFFF
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue