mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-26 07:39:56 -06:00
convert SPU to OOP
This commit is contained in:
118
src/SPU.h
118
src/SPU.h
@ -20,51 +20,30 @@
|
||||
#define SPU_H
|
||||
|
||||
#include "Savestate.h"
|
||||
#include "Platform.h"
|
||||
|
||||
namespace SPU
|
||||
{
|
||||
class SPU;
|
||||
|
||||
bool Init();
|
||||
void DeInit();
|
||||
void Reset();
|
||||
void Stop();
|
||||
|
||||
void DoSavestate(Savestate* file);
|
||||
|
||||
void SetPowerCnt(u32 val);
|
||||
|
||||
// 0=none 1=linear 2=cosine 3=cubic
|
||||
void SetInterpolation(int type);
|
||||
|
||||
void SetBias(u16 bias);
|
||||
void SetDegrade10Bit(bool enable);
|
||||
void SetApplyBias(bool enable);
|
||||
|
||||
void Mix(u32 dummy);
|
||||
|
||||
void TrimOutput();
|
||||
void DrainOutput();
|
||||
void InitOutput();
|
||||
int GetOutputSize();
|
||||
void Sync(bool wait);
|
||||
int ReadOutput(s16* data, int samples);
|
||||
void TransferOutput();
|
||||
|
||||
u8 Read8(u32 addr);
|
||||
u16 Read16(u32 addr);
|
||||
u32 Read32(u32 addr);
|
||||
void Write8(u32 addr, u8 val);
|
||||
void Write16(u32 addr, u16 val);
|
||||
void Write32(u32 addr, u32 val);
|
||||
|
||||
class Channel
|
||||
class SPUChannel
|
||||
{
|
||||
public:
|
||||
Channel(u32 num);
|
||||
~Channel();
|
||||
SPUChannel(u32 num);
|
||||
~SPUChannel();
|
||||
void Reset();
|
||||
void DoSavestate(Savestate* file);
|
||||
|
||||
static const s8 ADPCMIndexTable[8];
|
||||
static const u16 ADPCMTable[89];
|
||||
static const s16 PSGTable[8][8];
|
||||
|
||||
static s16 InterpCos[0x100];
|
||||
static s16 InterpCubic[0x100][4];
|
||||
static bool InterpInited;
|
||||
|
||||
// audio interpolation is an improvement upon the original hardware
|
||||
// (which performs no interpolation)
|
||||
int InterpType;
|
||||
|
||||
u32 Num;
|
||||
|
||||
u32 Cnt;
|
||||
@ -164,11 +143,11 @@ private:
|
||||
u32 (*BusRead32)(u32 addr);
|
||||
};
|
||||
|
||||
class CaptureUnit
|
||||
class SPUCaptureUnit
|
||||
{
|
||||
public:
|
||||
CaptureUnit(u32 num);
|
||||
~CaptureUnit();
|
||||
SPUCaptureUnit(u32 num);
|
||||
~SPUCaptureUnit();
|
||||
void Reset();
|
||||
void DoSavestate(Savestate* file);
|
||||
|
||||
@ -221,6 +200,61 @@ private:
|
||||
void (*BusWrite32)(u32 addr, u32 val);
|
||||
};
|
||||
|
||||
}
|
||||
class SPU
|
||||
{
|
||||
public:
|
||||
SPU();
|
||||
~SPU();
|
||||
void Reset();
|
||||
void DoSavestate(Savestate* file);
|
||||
|
||||
void Stop();
|
||||
|
||||
void SetPowerCnt(u32 val);
|
||||
|
||||
// 0=none 1=linear 2=cosine 3=cubic
|
||||
void SetInterpolation(int type);
|
||||
|
||||
void SetBias(u16 bias);
|
||||
void SetDegrade10Bit(bool enable);
|
||||
void SetApplyBias(bool enable);
|
||||
|
||||
void Mix(u32 dummy);
|
||||
|
||||
void TrimOutput();
|
||||
void DrainOutput();
|
||||
void InitOutput();
|
||||
int GetOutputSize();
|
||||
void Sync(bool wait);
|
||||
int ReadOutput(s16* data, int samples);
|
||||
void TransferOutput();
|
||||
|
||||
u8 Read8(u32 addr);
|
||||
u16 Read16(u32 addr);
|
||||
u32 Read32(u32 addr);
|
||||
void Write8(u32 addr, u8 val);
|
||||
void Write16(u32 addr, u16 val);
|
||||
void Write32(u32 addr, u32 val);
|
||||
|
||||
private:
|
||||
static const u32 OutputBufferSize = 2*2048;
|
||||
s16 OutputBackbuffer[2 * OutputBufferSize];
|
||||
u32 OutputBackbufferWritePosition;
|
||||
|
||||
s16 OutputFrontBuffer[2 * OutputBufferSize];
|
||||
u32 OutputFrontBufferWritePosition;
|
||||
u32 OutputFrontBufferReadPosition;
|
||||
|
||||
Platform::Mutex* AudioLock;
|
||||
|
||||
u16 Cnt;
|
||||
u8 MasterVolume;
|
||||
u16 Bias;
|
||||
bool ApplyBias;
|
||||
bool Degrade10Bit;
|
||||
|
||||
SPUChannel* Channels[16];
|
||||
SPUCaptureUnit* Capture[2];
|
||||
};
|
||||
|
||||
#endif // SPU_H
|
||||
|
Reference in New Issue
Block a user