diff --git a/Source/Core/Core/DSP/DSPAccelerator.cpp b/Source/Core/Core/DSP/DSPAccelerator.cpp index 67663b7795..457c37cda6 100644 --- a/Source/Core/Core/DSP/DSPAccelerator.cpp +++ b/Source/Core/Core/DSP/DSPAccelerator.cpp @@ -81,7 +81,7 @@ u16 Accelerator::ReadRaw() { // Set address back to start address (confirmed on hardware) m_current_address = m_start_address; - OnEndException(); + OnRawReadEndException(); } SetCurrentAddress(m_current_address); @@ -103,6 +103,7 @@ void Accelerator::WriteRaw(u16 value) WriteMemory(m_current_address * 2, value >> 8); WriteMemory(m_current_address * 2 + 1, value & 0xFF); m_current_address++; + OnRawWriteEndException(); } else { @@ -228,7 +229,7 @@ u16 Accelerator::ReadSample(const s16* coefs) // Set address back to start address. m_current_address = m_start_address; m_reads_stopped = true; - OnEndException(); + OnSampleReadEndException(); } SetCurrentAddress(m_current_address); diff --git a/Source/Core/Core/DSP/DSPAccelerator.h b/Source/Core/Core/DSP/DSPAccelerator.h index 723feaf52e..c0411fe94a 100644 --- a/Source/Core/Core/DSP/DSPAccelerator.h +++ b/Source/Core/Core/DSP/DSPAccelerator.h @@ -40,7 +40,9 @@ public: void DoState(PointerWrap& p); protected: - virtual void OnEndException() = 0; + virtual void OnRawReadEndException() = 0; + virtual void OnRawWriteEndException() = 0; + virtual void OnSampleReadEndException() = 0; virtual u8 ReadMemory(u32 address) = 0; virtual void WriteMemory(u32 address, u8 value) = 0; u16 GetCurrentSample(); diff --git a/Source/Core/Core/DSP/DSPCore.cpp b/Source/Core/Core/DSP/DSPCore.cpp index b6d89064b5..731d71e023 100644 --- a/Source/Core/Core/DSP/DSPCore.cpp +++ b/Source/Core/Core/DSP/DSPCore.cpp @@ -109,7 +109,18 @@ public: protected: u8 ReadMemory(u32 address) override { return Host::ReadHostMemory(address); } void WriteMemory(u32 address, u8 value) override { Host::WriteHostMemory(value, address); } - void OnEndException() override { m_dsp.SetException(ExceptionType::AcceleratorOverflow); } + void OnRawReadEndException() override + { + m_dsp.SetException(ExceptionType::AcceleratorRawReadOverflow); + } + void OnRawWriteEndException() override + { + m_dsp.SetException(ExceptionType::AcceleratorRawWriteOverflow); + } + void OnSampleReadEndException() override + { + m_dsp.SetException(ExceptionType::AcceleratorSampleReadOverflow); + } private: SDSP& m_dsp; diff --git a/Source/Core/Core/DSP/DSPCore.h b/Source/Core/Core/DSP/DSPCore.h index da21e00837..b8fa5683c4 100644 --- a/Source/Core/Core/DSP/DSPCore.h +++ b/Source/Core/Core/DSP/DSPCore.h @@ -226,13 +226,13 @@ enum : u16 // Exception vectors enum class ExceptionType { - StackOverflow = 1, // 0x0002 stack under/over flow - EXP_2 = 2, // 0x0004 - EXP_3 = 3, // 0x0006 - EXP_4 = 4, // 0x0008 - AcceleratorOverflow = 5, // 0x000a accelerator address overflow - EXP_6 = 6, // 0x000c - ExternalInterrupt = 7 // 0x000e external int (message from CPU) + StackOverflow = 1, // 0x0002 stack under/over flow + EXP_2 = 2, // 0x0004 + AcceleratorRawReadOverflow = 3, // 0x0006 accelerator raw read address overflow + AcceleratorRawWriteOverflow = 4, // 0x0008 accelerator raw write address overflow + AcceleratorSampleReadOverflow = 5, // 0x000a accelerator sample reads address overflow + EXP_6 = 6, // 0x000c + ExternalInterrupt = 7 // 0x000e external int (message from CPU) }; enum class Mailbox diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/AESnd.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/AESnd.cpp index 5084a6ed24..0f8467f693 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/AESnd.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/AESnd.cpp @@ -246,7 +246,7 @@ AESndAccelerator::AESndAccelerator(DSP::DSPManager& dsp) : m_dsp(dsp) AESndAccelerator::~AESndAccelerator() = default; -void AESndAccelerator::OnEndException() +void AESndAccelerator::OnSampleReadEndException() { // exception5 - this updates internal state SetYn1(GetYn1()); @@ -372,7 +372,7 @@ void AESndUCode::DoMixing() while (counter_h >= 1) { counter_h--; - new_r = m_accelerator.Read(ACCELERATOR_COEFS.data()); + new_r = m_accelerator.ReadSample(ACCELERATOR_COEFS.data()); new_l = new_r; } break; @@ -383,8 +383,8 @@ void AESndUCode::DoMixing() while (counter_h >= 1) { counter_h--; - new_r = m_accelerator.Read(ACCELERATOR_COEFS.data()); - new_l = m_accelerator.Read(ACCELERATOR_COEFS.data()); + new_r = m_accelerator.ReadSample(ACCELERATOR_COEFS.data()); + new_l = m_accelerator.ReadSample(ACCELERATOR_COEFS.data()); } break; // falls through to mix_samples normally @@ -394,7 +394,7 @@ void AESndUCode::DoMixing() while (counter_h >= 1) { counter_h--; - new_r = m_accelerator.Read(ACCELERATOR_COEFS.data()); + new_r = m_accelerator.ReadSample(ACCELERATOR_COEFS.data()); new_l = new_r; } new_r ^= 0x8000; @@ -407,8 +407,8 @@ void AESndUCode::DoMixing() while (counter_h >= 1) { counter_h--; - new_r = m_accelerator.Read(ACCELERATOR_COEFS.data()); - new_l = m_accelerator.Read(ACCELERATOR_COEFS.data()); + new_r = m_accelerator.ReadSample(ACCELERATOR_COEFS.data()); + new_l = m_accelerator.ReadSample(ACCELERATOR_COEFS.data()); } new_r ^= 0x8000; new_l ^= 0x8000; diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/AESnd.h b/Source/Core/Core/HW/DSPHLE/UCodes/AESnd.h index 874e0440db..ebd644b757 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/AESnd.h +++ b/Source/Core/Core/HW/DSPHLE/UCodes/AESnd.h @@ -30,7 +30,9 @@ public: ~AESndAccelerator(); protected: - void OnEndException() override; + void OnRawReadEndException() override {} + void OnRawWriteEndException() override {} + void OnSampleReadEndException() override; u8 ReadMemory(u32 address) override; void WriteMemory(u32 address, u8 value) override; diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/AXVoice.h b/Source/Core/Core/HW/DSPHLE/UCodes/AXVoice.h index c7d070750f..e5aefd0c77 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/AXVoice.h +++ b/Source/Core/Core/HW/DSPHLE/UCodes/AXVoice.h @@ -134,7 +134,9 @@ public: PB_TYPE* acc_pb = nullptr; protected: - void OnEndException() override + void OnRawReadEndException() override {} + void OnRawWriteEndException() override {} + void OnSampleReadEndException() override { if (acc_pb->audio_addr.looping) { diff --git a/Source/UnitTests/Core/DSP/DSPAcceleratorTest.cpp b/Source/UnitTests/Core/DSP/DSPAcceleratorTest.cpp index a78a09f5ad..77963d7df0 100644 --- a/Source/UnitTests/Core/DSP/DSPAcceleratorTest.cpp +++ b/Source/UnitTests/Core/DSP/DSPAcceleratorTest.cpp @@ -23,7 +23,9 @@ public: bool EndExceptionRaised() const { return m_accov_raised; } protected: - void OnEndException() override + void OnRawReadEndException() override {} + void OnRawWriteEndException() override {} + void OnSampleReadEndException() override { EXPECT_TRUE(m_reads_stopped); m_accov_raised = true;