mirror of
https://github.com/ARMSX2/ARMSX2.git
synced 2026-08-24 16:50:16 -07:00
Accept the two legacy majors at the version gate and route them to the legacy reader, so states from AetherSX2 v1.5-era builds and NetherSX2 v2.1 load in place. Re-saving one writes a current-format state, which is the whole of the conversion story. Three of the zip entries need era-specific handling, so entries now declare how they survive a legacy load: - GS carries its own version, which Defrost still reads back through these eras. Only its size has to come from the zip entry rather than from today's component, since the generic reader would otherwise demand a current-sized block and reject a short read. - SPU2 shares only its head (registers and sample RAM) across eras; its tail was re-laid-out repeatedly while the block's self-version stayed at 0xe, so the self-version cannot arbitrate it and ThawIt must never see one. The new SPU2freezeLegacy restores the memory and resets the cores instead, which costs a note in flight and nothing else. - PAD, USB and achievements predate the StateWrapper streams that read them today. They are skipped, and correspondingly not required to be present: the pads keep the type and mode they booted with. The GS entry's existing overrides gain the `override` keyword, which adding one to the class now requires.
106 lines
3.0 KiB
C++
106 lines
3.0 KiB
C++
// SPDX-FileCopyrightText: 2002-2026 PCSX2 Dev Team
|
|
// SPDX-License-Identifier: GPL-3.0+
|
|
|
|
#pragma once
|
|
|
|
#include "SaveState.h"
|
|
#include "IopCounters.h"
|
|
|
|
#include <memory>
|
|
|
|
struct Pcsx2Config;
|
|
|
|
class AudioStream;
|
|
|
|
namespace SPU2
|
|
{
|
|
/// PS2/Native Sample Rate.
|
|
static constexpr u32 SAMPLE_RATE = 48000;
|
|
|
|
/// PSX Mode Sample Rate.
|
|
static constexpr u32 PSX_SAMPLE_RATE = 44100;
|
|
|
|
/// Open/close, call at VM startup/shutdown.
|
|
bool Open();
|
|
void Close();
|
|
|
|
/// Reset, rebooting VM or going into PSX mode.
|
|
void Reset(bool psxmode);
|
|
|
|
/// Identifies any configuration changes and applies them.
|
|
void CheckForConfigChanges(const Pcsx2Config& old_config);
|
|
|
|
/// Returns the current output volume, irrespective of the configuration.
|
|
u32 GetOutputVolume();
|
|
|
|
/// Directly updates the output volume without going through the configuration.
|
|
void SetOutputVolume(u32 volume);
|
|
|
|
/// Sets up muting and unmuting and reports success or failure.
|
|
bool SetOutputMuted(const bool muted);
|
|
|
|
/// Returns true if the output is muted (distinct from 0%).
|
|
bool IsOutputMuted();
|
|
|
|
/// Swaps the final stereo output channels (L<->R) for devices forced into
|
|
/// reverse-landscape (flipped physical speakers, e.g. Clamp pad).
|
|
void SetSwapChannels(bool swap);
|
|
|
|
/// Returns true if the final stereo output is L<->R swapped.
|
|
bool IsSwapChannels();
|
|
|
|
/// Updates the current volume based on running state.
|
|
void UpdateOutputVolume();
|
|
|
|
/// Saves the current volume based on running state.
|
|
void SaveOutputVolume();
|
|
|
|
/// Pauses/resumes the output stream.
|
|
void SetOutputPaused(bool paused);
|
|
|
|
/// When suppressed, SetOutputPaused() is a no-op so the audio device stays
|
|
/// running across a transient VM park (e.g. settings-apply), preventing the
|
|
/// OS from reclaiming the low-latency stream during a long park.
|
|
void SetOutputPauseSuppressed(bool suppressed);
|
|
|
|
/// Clears output buffers in no-sync mode, prevents long delays after fast forwarding.
|
|
void OnTargetSpeedChanged();
|
|
|
|
/// Returns true if we're currently running in PSX mode.
|
|
bool IsRunningPSXMode();
|
|
|
|
/// Returns the current sample rate the SPU2 is operating at.
|
|
u32 GetConsoleSampleRate();
|
|
|
|
/// Tells SPU2 to forward audio packets to GSCapture.
|
|
void SetAudioCaptureActive(bool active);
|
|
bool IsAudioCaptureActive();
|
|
// libretro: direct access to the output stream so the frontend can pull
|
|
// mixed frames from retro_run.
|
|
AudioStream* GetOutputStream();
|
|
} // namespace SPU2
|
|
|
|
void SPU2write(u32 mem, u16 value);
|
|
u16 SPU2read(u32 mem);
|
|
|
|
void SPU2async();
|
|
s32 SPU2freeze(FreezeAction mode, freezeData* data);
|
|
|
|
// Partial restore from a legacy-format (AetherSX2-era) SPU2 block, whose tail
|
|
// cannot be replayed. See the definition for what is and is not kept.
|
|
s32 SPU2freezeLegacy(const void* data, size_t size);
|
|
|
|
void SPU2readDMA4Mem(u16* pMem, u32 size);
|
|
void SPU2writeDMA4Mem(u16* pMem, u32 size);
|
|
void SPU2interruptDMA4();
|
|
void SPU2interruptDMA7();
|
|
void SPU2readDMA7Mem(u16* pMem, u32 size);
|
|
void SPU2writeDMA7Mem(u16* pMem, u32 size);
|
|
|
|
extern u64 lClocks;
|
|
|
|
extern void CounterUpdate(u32 DMAICounter);
|
|
extern void TimeUpdate(u32 cClocks);
|
|
extern void SPU2_FastWrite(u32 rmem, u16 value);
|
|
|