2022-12-04 11:03:45 +00:00
|
|
|
// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
|
|
|
|
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
|
|
|
|
2019-09-24 13:44:38 +00:00
|
|
|
#pragma once
|
2020-11-11 14:56:24 +00:00
|
|
|
#include "types.h"
|
2019-09-24 13:44:38 +00:00
|
|
|
#include <array>
|
|
|
|
|
|
|
|
class StateWrapper;
|
|
|
|
|
2022-07-11 13:03:29 +00:00
|
|
|
class AudioStream;
|
|
|
|
|
2022-08-01 13:39:41 +00:00
|
|
|
namespace SPU {
|
2019-09-24 13:44:38 +00:00
|
|
|
|
2022-08-01 13:39:41 +00:00
|
|
|
enum : u32
|
2019-09-24 13:44:38 +00:00
|
|
|
{
|
2022-08-01 13:39:41 +00:00
|
|
|
RAM_SIZE = 512 * 1024,
|
|
|
|
RAM_MASK = RAM_SIZE - 1,
|
|
|
|
SAMPLE_RATE = 44100,
|
|
|
|
};
|
2019-09-24 13:44:38 +00:00
|
|
|
|
2022-08-01 13:39:41 +00:00
|
|
|
void Initialize();
|
|
|
|
void CPUClockChanged();
|
|
|
|
void Shutdown();
|
|
|
|
void Reset();
|
|
|
|
bool DoState(StateWrapper& sw);
|
2019-10-10 16:20:21 +00:00
|
|
|
|
2022-08-01 13:39:41 +00:00
|
|
|
u16 ReadRegister(u32 offset);
|
|
|
|
void WriteRegister(u32 offset, u16 value);
|
2019-10-11 03:24:48 +00:00
|
|
|
|
2022-08-01 13:39:41 +00:00
|
|
|
void DMARead(u32* words, u32 word_count);
|
|
|
|
void DMAWrite(const u32* words, u32 word_count);
|
2019-10-20 09:46:35 +00:00
|
|
|
|
2022-08-01 13:39:41 +00:00
|
|
|
// Render statistics debug window.
|
|
|
|
void DrawDebugStateWindow();
|
2020-03-23 14:22:02 +00:00
|
|
|
|
2022-08-01 13:39:41 +00:00
|
|
|
// Executes the SPU, generating any pending samples.
|
|
|
|
void GeneratePendingSamples();
|
2019-10-10 16:20:21 +00:00
|
|
|
|
2022-08-01 13:39:41 +00:00
|
|
|
/// Returns true if currently dumping audio.
|
|
|
|
bool IsDumpingAudio();
|
2020-03-22 14:29:00 +00:00
|
|
|
|
2022-08-01 13:39:41 +00:00
|
|
|
/// Starts dumping audio to file.
|
|
|
|
bool StartDumpingAudio(const char* filename);
|
2020-03-17 02:48:03 +00:00
|
|
|
|
2022-08-01 13:39:41 +00:00
|
|
|
/// Stops dumping audio to file, if started.
|
|
|
|
bool StopDumpingAudio();
|
2020-03-28 15:12:37 +00:00
|
|
|
|
2022-08-01 13:39:41 +00:00
|
|
|
/// Access to SPU RAM.
|
|
|
|
const std::array<u8, RAM_SIZE>& GetRAM();
|
|
|
|
std::array<u8, RAM_SIZE>& GetWritableRAM();
|
2020-03-28 15:12:37 +00:00
|
|
|
|
2022-08-01 13:39:41 +00:00
|
|
|
/// Change output stream - used for runahead.
|
|
|
|
// TODO: Make it use system "running ahead" flag
|
|
|
|
bool IsAudioOutputMuted();
|
|
|
|
void SetAudioOutputMuted(bool muted);
|
2021-08-07 03:21:53 +00:00
|
|
|
|
2022-08-01 13:39:41 +00:00
|
|
|
AudioStream* GetOutputStream();
|
|
|
|
void RecreateOutputStream();
|
2020-07-31 07:09:18 +00:00
|
|
|
|
2022-08-01 13:39:41 +00:00
|
|
|
}; // namespace SPU
|