CDROM: Move audio FIFO to CDROM class and skip sectors when unempty

Fixes cutscene audio in Nickelodeon Rugrats - Search for Reptar.
This commit is contained in:
Connor McLaughlin
2020-07-22 00:03:44 +10:00
parent f9bbbbbaec
commit f28ef01d24
6 changed files with 90 additions and 105 deletions

View File

@ -14,6 +14,7 @@ class WAVWriter;
class System;
class TimingEvent;
class DMA;
class CDROM;
class InterruptController;
class SPU
@ -22,7 +23,7 @@ public:
SPU();
~SPU();
void Initialize(System* system, DMA* dma, InterruptController* interrupt_controller);
void Initialize(System* system, DMA* dma, CDROM* cdrom, InterruptController* interrupt_controller);
void Reset();
bool DoState(StateWrapper& sw);
@ -35,14 +36,6 @@ public:
// Render statistics debug window.
void DrawDebugStateWindow();
// External input from CD controller.
void AddCDAudioSample(s16 left, s16 right)
{
m_cd_audio_buffer.Push(left);
m_cd_audio_buffer.Push(right);
}
void EnsureCDAudioSpace(u32 num_samples);
// Executes the SPU, generating any pending samples.
void GeneratePendingSamples();
@ -67,7 +60,6 @@ private:
static constexpr u32 SYSCLK_TICKS_PER_SPU_TICK = MASTER_CLOCK / SAMPLE_RATE; // 0x300
static constexpr s16 ENVELOPE_MIN_VOLUME = 0;
static constexpr s16 ENVELOPE_MAX_VOLUME = 0x7FFF;
static constexpr u32 CD_AUDIO_SAMPLE_BUFFER_SIZE = 44100 * 2;
static constexpr u32 CAPTURE_BUFFER_SIZE_PER_CHANNEL = 0x400;
static constexpr u32 MINIMUM_TICKS_BETWEEN_KEY_ON_OFF = 2;
static constexpr u32 NUM_REVERB_REGS = 32;
@ -331,10 +323,7 @@ private:
};
};
static constexpr s32 Clamp16(s32 value)
{
return (value < -0x8000) ? -0x8000 : (value > 0x7FFF) ? 0x7FFF : value;
}
static constexpr s32 Clamp16(s32 value) { return (value < -0x8000) ? -0x8000 : (value > 0x7FFF) ? 0x7FFF : value; }
static constexpr s32 ApplyVolume(s32 sample, s16 volume) { return (sample * s32(volume)) >> 15; }
@ -382,6 +371,7 @@ private:
System* m_system = nullptr;
DMA* m_dma = nullptr;
CDROM* m_cdrom = nullptr;
InterruptController* m_interrupt_controller = nullptr;
std::unique_ptr<TimingEvent> m_tick_event;
std::unique_ptr<TimingEvent> m_transfer_event;
@ -431,6 +421,4 @@ private:
InlineFIFOQueue<u16, FIFO_SIZE_IN_HALFWORDS> m_transfer_fifo;
std::array<u8, RAM_SIZE> m_ram{};
InlineFIFOQueue<s16, CD_AUDIO_SAMPLE_BUFFER_SIZE> m_cd_audio_buffer;
};