Duckstation/src/core/spu.h

61 lines
1.3 KiB
C
Raw Normal View History

// SPDX-FileCopyrightText: 2019-2022 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once
#include "types.h"
#include <array>
class StateWrapper;
class AudioStream;
2022-08-01 13:39:41 +00:00
namespace SPU {
2022-08-01 13:39:41 +00:00
enum : u32
{
2022-08-01 13:39:41 +00:00
RAM_SIZE = 512 * 1024,
RAM_MASK = RAM_SIZE - 1,
SAMPLE_RATE = 44100,
};
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();
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);
2022-08-01 13:39:41 +00:00
/// Stops dumping audio to file, if started.
bool StopDumpingAudio();
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();
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);
2022-08-01 13:39:41 +00:00
AudioStream* GetOutputStream();
void RecreateOutputStream();
JIT optimizations and refactoring (#675) * CPU/Recompiler: Use rel32 call where possible for no-args * JitCodeBuffer: Support using preallocated buffer * CPU/Recompiler/AArch64: Use bl instead of blr for short branches * CPU/CodeCache: Allocate recompiler buffer in program space This means we don't need 64-bit moves for every call out of the recompiler. * GTE: Don't store as u16 and load as u32 * CPU/Recompiler: Add methods to emit global load/stores * GTE: Convert class to namespace * CPU/Recompiler: Call GTE functions directly * Settings: Turn into a global variable * GPU: Replace local pointers with global * InterruptController: Turn into a global pointer * System: Replace local pointers with global * Timers: Turn into a global instance * DMA: Turn into a global instance * SPU: Turn into a global instance * CDROM: Turn into a global instance * MDEC: Turn into a global instance * Pad: Turn into a global instance * SIO: Turn into a global instance * CDROM: Move audio FIFO to the heap * CPU/Recompiler: Drop ASMFunctions No longer needed since we have code in the same 4GB window. * CPUCodeCache: Turn class into namespace * Bus: Local pointer -> global pointers * CPU: Turn class into namespace * Bus: Turn into namespace * GTE: Store registers in CPU state struct Allows relative addressing on ARM. * CPU/Recompiler: Align code storage to page size * CPU/Recompiler: Fix relative branches on A64 * HostInterface: Local references to global * System: Turn into a namespace, move events out * Add guard pages * Android: Fix build
2020-07-31 07:09:18 +00:00
2022-08-01 13:39:41 +00:00
}; // namespace SPU