mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-06 14:15:41 +12:00
HLE DSP: Add region handling
This commit is contained in:
parent
a85ca0459a
commit
4070bea697
1 changed files with 22 additions and 2 deletions
|
@ -18,11 +18,31 @@ namespace Audio {
|
|||
DSPState dspState;
|
||||
|
||||
std::array<std::vector<u8>, pipeCount> pipeData; // The data of each pipe
|
||||
std::array<u8, Memory::DSP_RAM_SIZE> dspRam;
|
||||
Audio::HLE::DspMemory dspRam;
|
||||
|
||||
void resetAudioPipe();
|
||||
bool loaded = false; // Have we loaded a component?
|
||||
|
||||
// Get the index for the current region we'll be reading. Returns the region with the highest frame counter
|
||||
// Accounting for whether one of the frame counters has wrapped around
|
||||
usize readRegionIndex() const {
|
||||
const auto counter0 = dspRam.region0.frameCounter;
|
||||
const auto counter1 = dspRam.region1.frameCounter;
|
||||
|
||||
// Handle wraparound cases first
|
||||
if (counter0 == 0xffff && counter1 != 0xfffe) {
|
||||
return 1;
|
||||
} else if (counter1 == 0xffff && counter0 != 0xfffe) {
|
||||
return 0;
|
||||
} else {
|
||||
return counter0 > counter1 ? 0 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
// DSP shared memory is double buffered; One region is being written to while the other one is being read from
|
||||
Audio::HLE::SharedMemory& readRegion() { return readRegionIndex() == 0 ? dspRam.region0 : dspRam.region1; }
|
||||
Audio::HLE::SharedMemory& writeRegion() { return readRegionIndex() == 0 ? dspRam.region1 : dspRam.region0; }
|
||||
|
||||
public:
|
||||
HLE_DSP(Memory& mem, Scheduler& scheduler, DSPService& dspService) : DSPCore(mem, scheduler, dspService) {}
|
||||
~HLE_DSP() override {}
|
||||
|
@ -30,7 +50,7 @@ namespace Audio {
|
|||
void reset() override;
|
||||
void runAudioFrame() override;
|
||||
|
||||
u8* getDspMemory() override { return dspRam.data(); }
|
||||
u8* getDspMemory() override { return dspRam.rawMemory.data(); }
|
||||
|
||||
u16 recvData(u32 regId) override;
|
||||
bool recvDataIsReady(u32 regId) override { return true; } // Treat data as always ready
|
||||
|
|
Loading…
Add table
Reference in a new issue