yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::emu::Dsp Class Reference

#include <dsp.h>

Collaboration diagram for yaze::emu::Dsp:

Public Member Functions

 Dsp (std::vector< uint8_t > &aram)
 
void NewFrame ()
 
void Reset ()
 
void SaveState (std::ostream &stream)
 
void LoadState (std::istream &stream)
 
void Cycle ()
 
void HandleEcho ()
 
void CycleChannel (int ch)
 
void HandleNoise ()
 
void HandleGain (int ch)
 
bool CheckCounter (int rate)
 
void DecodeBrr (int ch)
 
uint8_t Read (uint8_t adr)
 
void Write (uint8_t adr, uint8_t val)
 
int16_t GetSample (int ch)
 
void GetSamples (int16_t *sample_data, int samples_per_frame, bool pal_timing)
 
int CopyNativeFrame (int16_t *sample_data, bool pal_timing)
 
void SetChannelMute (int ch, bool mute)
 
bool GetChannelMute (int ch) const
 
const DspChannelGetChannel (int ch) const
 
const int16_t * GetSampleBuffer () const
 
uint16_t GetSampleOffset () const
 
void ResetSampleBuffer ()
 
uint32_t GetFrameBoundary () const
 
int8_t GetMasterVolumeL () const
 
int8_t GetMasterVolumeR () const
 
bool IsMuted () const
 
bool IsReset () const
 
bool IsEchoEnabled () const
 
uint16_t GetEchoDelay () const
 

Public Attributes

InterpolationType interpolation_type = InterpolationType::Gaussian
 

Private Attributes

int16_t sampleBuffer [0x800 *2]
 
uint16_t sampleOffset
 
bool debug_mute_channels_ [8] = {false}
 
std::vector< uint8_t > & aram_
 
uint8_t ram [0x80]
 
DspChannel channel [8]
 
uint16_t counter
 
uint16_t dirPage
 
bool evenCycle
 
bool mute
 
bool reset
 
int8_t masterVolumeL
 
int8_t masterVolumeR
 
int16_t sampleOutL
 
int16_t sampleOutR
 
int16_t echoOutL
 
int16_t echoOutR
 
int16_t noiseSample
 
uint8_t noiseRate
 
bool echoWrites
 
int8_t echoVolumeL
 
int8_t echoVolumeR
 
int8_t feedbackVolume
 
uint16_t echoBufferAdr
 
uint16_t echoDelay
 
uint16_t echoLength
 
uint16_t echoBufferIndex
 
uint8_t firBufferIndex
 
int8_t firValues [8]
 
int16_t firBufferL [8]
 
int16_t firBufferR [8]
 
uint32_t lastFrameBoundary
 

Detailed Description

The S-DSP is a digital signal processor generating the sound data.

A DSP register can be selected with $F2, after which it can be read or written at $F3. Often it is useful to load the register address into A, and the value to send in Y, so that MOV $F2, YA can be used to do both in one 16-bit instruction.

The DSP register address space only has 7 bits. The high bit of $F2, if set, will make the selected register read-only via $F3.

When initializing the DSP registers for the first time, take care not to accidentally enable echo writeback via FLG, because it will immediately begin overwriting values in RAM.

Voices There are 8 voices, numbered 0 to 7. Each voice X has 10 registers in the range $X0-$X9.

| Name | Address | Bits | Notes | |------—|------—|--------—|-----------------------------------------------------—| | VOL (L) | $X0 | SVVV VVVV | Left channel volume, signed. | | VOL (R) | $X1 | SVVV VVVV | Right channel volume, signed. | | P (L) | $X2 | LLLL LLLL | Low 8 bits of sample pitch. | | P (H) | $X3 | –HH HHHH | High 6 bits of sample pitch. | | SCRN | $X4 | SSSS SSSS | Selects a sample source entry from the directory. | | ADSR (1)| $X5 | EDDD AAAA | ADSR enable (E), decay rate (D), attack rate (A). | | ADSR (2)| $X6 | SSSR RRRR | Sustain level (S), release rate (R). | | GAIN | $X7 | 0VVV VVVV 1MMV VVVV | Mode (M), value (V). | | ENVX | $X8 | 0VVV VVVV | Reads current 7-bit value of ADSR/GAIN envelope. | | OUTX | $X9 | SVVV VVVV | Reads signed 8-bit value of current sample wave | | | | | multiplied by ENVX, before applying VOL. |

Definition at line 88 of file dsp.h.

Constructor & Destructor Documentation

◆ Dsp()

yaze::emu::Dsp::Dsp ( std::vector< uint8_t > & aram)
inline

Definition at line 90 of file dsp.h.

Member Function Documentation

◆ NewFrame()

void yaze::emu::Dsp::NewFrame ( )

Definition at line 130 of file dsp.cc.

References lastFrameBoundary, and sampleOffset.

◆ Reset()

◆ SaveState()

◆ LoadState()

◆ Cycle()

void yaze::emu::Dsp::Cycle ( )

Definition at line 142 of file dsp.cc.

References counter, CycleChannel(), echoOutL, echoOutR, evenCycle, HandleEcho(), HandleNoise(), mute, sampleBuffer, sampleOffset, sampleOutL, and sampleOutR.

Referenced by yaze::emu::Apu::Cycle().

Here is the call graph for this function:

◆ HandleEcho()

◆ CycleChannel()

◆ HandleNoise()

void yaze::emu::Dsp::HandleNoise ( )

Definition at line 476 of file dsp.cc.

References CheckCounter(), noiseRate, and noiseSample.

Referenced by Cycle().

Here is the call graph for this function:

◆ HandleGain()

◆ CheckCounter()

bool yaze::emu::Dsp::CheckCounter ( int rate)

Definition at line 192 of file dsp.cc.

References counter.

Referenced by HandleGain(), and HandleNoise().

◆ DecodeBrr()

◆ Read()

uint8_t yaze::emu::Dsp::Read ( uint8_t adr)

Definition at line 483 of file dsp.cc.

References ram.

Referenced by yaze::emu::Apu::Read().

◆ Write()

◆ GetSample()

int16_t yaze::emu::Dsp::GetSample ( int ch)

Definition at line 417 of file dsp.cc.

References channel, yaze::emu::DspChannel::decodeBuffer, and yaze::emu::DspChannel::pitchCounter.

Referenced by CycleChannel().

◆ GetSamples()

void yaze::emu::Dsp::GetSamples ( int16_t * sample_data,
int samples_per_frame,
bool pal_timing )

◆ CopyNativeFrame()

int yaze::emu::Dsp::CopyNativeFrame ( int16_t * sample_data,
bool pal_timing )

Definition at line 848 of file dsp.cc.

References lastFrameBoundary, and sampleBuffer.

◆ SetChannelMute()

void yaze::emu::Dsp::SetChannelMute ( int ch,
bool mute )
inline

Definition at line 119 of file dsp.h.

References debug_mute_channels_, and mute.

◆ GetChannelMute()

bool yaze::emu::Dsp::GetChannelMute ( int ch) const
inline

Definition at line 122 of file dsp.h.

References debug_mute_channels_.

◆ GetChannel()

const DspChannel & yaze::emu::Dsp::GetChannel ( int ch) const
inline

Definition at line 128 of file dsp.h.

References channel.

◆ GetSampleBuffer()

const int16_t * yaze::emu::Dsp::GetSampleBuffer ( ) const
inline

Definition at line 136 of file dsp.h.

References sampleBuffer.

◆ GetSampleOffset()

uint16_t yaze::emu::Dsp::GetSampleOffset ( ) const
inline

Definition at line 137 of file dsp.h.

References sampleOffset.

◆ ResetSampleBuffer()

void yaze::emu::Dsp::ResetSampleBuffer ( )

Definition at line 134 of file dsp.cc.

References lastFrameBoundary, sampleBuffer, and sampleOffset.

◆ GetFrameBoundary()

uint32_t yaze::emu::Dsp::GetFrameBoundary ( ) const
inline

Definition at line 144 of file dsp.h.

References lastFrameBoundary.

◆ GetMasterVolumeL()

int8_t yaze::emu::Dsp::GetMasterVolumeL ( ) const
inline

Definition at line 145 of file dsp.h.

References masterVolumeL.

◆ GetMasterVolumeR()

int8_t yaze::emu::Dsp::GetMasterVolumeR ( ) const
inline

Definition at line 146 of file dsp.h.

References masterVolumeR.

◆ IsMuted()

bool yaze::emu::Dsp::IsMuted ( ) const
inline

Definition at line 147 of file dsp.h.

References mute.

◆ IsReset()

bool yaze::emu::Dsp::IsReset ( ) const
inline

Definition at line 148 of file dsp.h.

References reset.

◆ IsEchoEnabled()

bool yaze::emu::Dsp::IsEchoEnabled ( ) const
inline

Definition at line 149 of file dsp.h.

References echoWrites.

◆ GetEchoDelay()

uint16_t yaze::emu::Dsp::GetEchoDelay ( ) const
inline

Definition at line 150 of file dsp.h.

References echoDelay.

Member Data Documentation

◆ interpolation_type

InterpolationType yaze::emu::Dsp::interpolation_type = InterpolationType::Gaussian

Definition at line 153 of file dsp.h.

Referenced by GetSamples().

◆ sampleBuffer

int16_t yaze::emu::Dsp::sampleBuffer[0x800 *2]
private

Definition at line 158 of file dsp.h.

Referenced by CopyNativeFrame(), Cycle(), GetSampleBuffer(), GetSamples(), Reset(), and ResetSampleBuffer().

◆ sampleOffset

uint16_t yaze::emu::Dsp::sampleOffset
private

Definition at line 159 of file dsp.h.

Referenced by Cycle(), GetSampleOffset(), NewFrame(), Reset(), and ResetSampleBuffer().

◆ debug_mute_channels_

bool yaze::emu::Dsp::debug_mute_channels_[8] = {false}
private

Definition at line 161 of file dsp.h.

Referenced by CycleChannel(), GetChannelMute(), and SetChannelMute().

◆ aram_

std::vector<uint8_t>& yaze::emu::Dsp::aram_
private

Definition at line 163 of file dsp.h.

Referenced by CycleChannel(), DecodeBrr(), and HandleEcho().

◆ ram

uint8_t yaze::emu::Dsp::ram[0x80]
private

Definition at line 166 of file dsp.h.

Referenced by CycleChannel(), LoadState(), Read(), Reset(), SaveState(), and Write().

◆ channel

DspChannel yaze::emu::Dsp::channel[8]
private

◆ counter

uint16_t yaze::emu::Dsp::counter
private

Definition at line 170 of file dsp.h.

Referenced by CheckCounter(), Cycle(), LoadState(), Reset(), and SaveState().

◆ dirPage

uint16_t yaze::emu::Dsp::dirPage
private

Definition at line 171 of file dsp.h.

Referenced by CycleChannel(), LoadState(), Reset(), SaveState(), and Write().

◆ evenCycle

bool yaze::emu::Dsp::evenCycle
private

Definition at line 172 of file dsp.h.

Referenced by Cycle(), CycleChannel(), LoadState(), Reset(), and SaveState().

◆ mute

bool yaze::emu::Dsp::mute
private

Definition at line 173 of file dsp.h.

Referenced by Cycle(), IsMuted(), LoadState(), Reset(), SaveState(), SetChannelMute(), and Write().

◆ reset

bool yaze::emu::Dsp::reset
private

Definition at line 174 of file dsp.h.

Referenced by CycleChannel(), IsReset(), LoadState(), Reset(), SaveState(), and Write().

◆ masterVolumeL

int8_t yaze::emu::Dsp::masterVolumeL
private

Definition at line 175 of file dsp.h.

Referenced by GetMasterVolumeL(), HandleEcho(), LoadState(), Reset(), SaveState(), and Write().

◆ masterVolumeR

int8_t yaze::emu::Dsp::masterVolumeR
private

Definition at line 176 of file dsp.h.

Referenced by GetMasterVolumeR(), HandleEcho(), LoadState(), Reset(), SaveState(), and Write().

◆ sampleOutL

int16_t yaze::emu::Dsp::sampleOutL
private

Definition at line 178 of file dsp.h.

Referenced by Cycle(), CycleChannel(), HandleEcho(), LoadState(), Reset(), and SaveState().

◆ sampleOutR

int16_t yaze::emu::Dsp::sampleOutR
private

Definition at line 179 of file dsp.h.

Referenced by Cycle(), CycleChannel(), HandleEcho(), LoadState(), Reset(), and SaveState().

◆ echoOutL

int16_t yaze::emu::Dsp::echoOutL
private

Definition at line 180 of file dsp.h.

Referenced by Cycle(), CycleChannel(), HandleEcho(), LoadState(), Reset(), and SaveState().

◆ echoOutR

int16_t yaze::emu::Dsp::echoOutR
private

Definition at line 181 of file dsp.h.

Referenced by Cycle(), CycleChannel(), HandleEcho(), LoadState(), Reset(), and SaveState().

◆ noiseSample

int16_t yaze::emu::Dsp::noiseSample
private

Definition at line 183 of file dsp.h.

Referenced by CycleChannel(), HandleNoise(), LoadState(), Reset(), and SaveState().

◆ noiseRate

uint8_t yaze::emu::Dsp::noiseRate
private

Definition at line 184 of file dsp.h.

Referenced by HandleNoise(), LoadState(), Reset(), SaveState(), and Write().

◆ echoWrites

bool yaze::emu::Dsp::echoWrites
private

Definition at line 186 of file dsp.h.

Referenced by HandleEcho(), IsEchoEnabled(), LoadState(), Reset(), SaveState(), and Write().

◆ echoVolumeL

int8_t yaze::emu::Dsp::echoVolumeL
private

Definition at line 187 of file dsp.h.

Referenced by HandleEcho(), LoadState(), Reset(), SaveState(), and Write().

◆ echoVolumeR

int8_t yaze::emu::Dsp::echoVolumeR
private

Definition at line 188 of file dsp.h.

Referenced by HandleEcho(), LoadState(), Reset(), SaveState(), and Write().

◆ feedbackVolume

int8_t yaze::emu::Dsp::feedbackVolume
private

Definition at line 189 of file dsp.h.

Referenced by HandleEcho(), LoadState(), Reset(), SaveState(), and Write().

◆ echoBufferAdr

uint16_t yaze::emu::Dsp::echoBufferAdr
private

Definition at line 190 of file dsp.h.

Referenced by HandleEcho(), LoadState(), Reset(), SaveState(), and Write().

◆ echoDelay

uint16_t yaze::emu::Dsp::echoDelay
private

Definition at line 191 of file dsp.h.

Referenced by GetEchoDelay(), HandleEcho(), LoadState(), Reset(), SaveState(), and Write().

◆ echoLength

uint16_t yaze::emu::Dsp::echoLength
private

Definition at line 192 of file dsp.h.

Referenced by HandleEcho(), LoadState(), Reset(), and SaveState().

◆ echoBufferIndex

uint16_t yaze::emu::Dsp::echoBufferIndex
private

Definition at line 193 of file dsp.h.

Referenced by HandleEcho(), LoadState(), Reset(), and SaveState().

◆ firBufferIndex

uint8_t yaze::emu::Dsp::firBufferIndex
private

Definition at line 194 of file dsp.h.

Referenced by HandleEcho(), LoadState(), Reset(), and SaveState().

◆ firValues

int8_t yaze::emu::Dsp::firValues[8]
private

Definition at line 195 of file dsp.h.

Referenced by HandleEcho(), LoadState(), Reset(), SaveState(), and Write().

◆ firBufferL

int16_t yaze::emu::Dsp::firBufferL[8]
private

Definition at line 196 of file dsp.h.

Referenced by HandleEcho(), LoadState(), Reset(), and SaveState().

◆ firBufferR

int16_t yaze::emu::Dsp::firBufferR[8]
private

Definition at line 197 of file dsp.h.

Referenced by HandleEcho(), LoadState(), Reset(), and SaveState().

◆ lastFrameBoundary

uint32_t yaze::emu::Dsp::lastFrameBoundary
private

The documentation for this class was generated from the following files: