#include <dsp.h>

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 DspChannel & | GetChannel (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 |
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. |
| void yaze::emu::Dsp::NewFrame | ( | ) |
Definition at line 130 of file dsp.cc.
References lastFrameBoundary, and sampleOffset.
| void yaze::emu::Dsp::Reset | ( | ) |
Definition at line 68 of file dsp.cc.
References yaze::emu::DspChannel::adsrState, yaze::emu::DspChannel::blockOffset, yaze::emu::DspChannel::brrHeader, yaze::emu::DspChannel::bufferOffset, channel, counter, yaze::emu::DspChannel::decodeOffset, yaze::emu::DspChannel::directGain, dirPage, echoBufferAdr, echoBufferIndex, echoDelay, yaze::emu::DspChannel::echoEnable, echoLength, echoOutL, echoOutR, echoVolumeL, echoVolumeR, echoWrites, evenCycle, feedbackVolume, firBufferIndex, firBufferL, firBufferR, firValues, yaze::emu::DspChannel::gain, yaze::emu::DspChannel::gainMode, yaze::emu::DspChannel::gainSustainLevel, yaze::emu::DspChannel::gainValue, yaze::emu::DspChannel::keyOff, yaze::emu::DspChannel::keyOn, lastFrameBoundary, masterVolumeL, masterVolumeR, mute, noiseRate, noiseSample, yaze::emu::DspChannel::pitch, yaze::emu::DspChannel::pitchCounter, yaze::emu::DspChannel::pitchModulation, yaze::emu::DspChannel::preclampGain, ram, reset, sampleBuffer, sampleOffset, yaze::emu::DspChannel::sampleOut, sampleOutL, sampleOutR, yaze::emu::DspChannel::srcn, yaze::emu::DspChannel::startDelay, yaze::emu::DspChannel::sustainLevel, yaze::emu::DspChannel::useGain, yaze::emu::DspChannel::useNoise, yaze::emu::DspChannel::volumeL, and yaze::emu::DspChannel::volumeR.
Referenced by yaze::emu::Apu::Reset().
| void yaze::emu::Dsp::SaveState | ( | std::ostream & | stream | ) |
Definition at line 868 of file dsp.cc.
References channel, counter, dirPage, echoBufferAdr, echoBufferIndex, echoDelay, echoLength, echoOutL, echoOutR, echoVolumeL, echoVolumeR, echoWrites, evenCycle, feedbackVolume, firBufferIndex, firBufferL, firBufferR, firValues, lastFrameBoundary, masterVolumeL, masterVolumeR, mute, noiseRate, noiseSample, ram, reset, sampleOutL, and sampleOutR.
Referenced by yaze::emu::Apu::SaveState().
| void yaze::emu::Dsp::LoadState | ( | std::istream & | stream | ) |
Definition at line 957 of file dsp.cc.
References channel, counter, dirPage, echoBufferAdr, echoBufferIndex, echoDelay, echoLength, echoOutL, echoOutR, echoVolumeL, echoVolumeR, echoWrites, evenCycle, feedbackVolume, firBufferIndex, firBufferL, firBufferR, firValues, lastFrameBoundary, masterVolumeL, masterVolumeR, mute, noiseRate, noiseSample, ram, reset, sampleOutL, and sampleOutR.
Referenced by yaze::emu::Apu::LoadState().
| 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().

| void yaze::emu::Dsp::HandleEcho | ( | ) |
Definition at line 198 of file dsp.cc.
References aram_, echoBufferAdr, echoBufferIndex, echoDelay, echoLength, echoOutL, echoOutR, echoVolumeL, echoVolumeR, echoWrites, feedbackVolume, firBufferIndex, firBufferL, firBufferR, firValues, masterVolumeL, masterVolumeR, sampleOutL, and sampleOutR.
Referenced by Cycle().
| void yaze::emu::Dsp::CycleChannel | ( | int | ch | ) |
Definition at line 252 of file dsp.cc.
References yaze::emu::DspChannel::adsrState, aram_, yaze::emu::DspChannel::blockOffset, yaze::emu::DspChannel::brrHeader, yaze::emu::DspChannel::bufferOffset, channel, debug_mute_channels_, DecodeBrr(), yaze::emu::DspChannel::decodeOffset, dirPage, echoOutL, echoOutR, evenCycle, yaze::emu::DspChannel::gain, GetSample(), HandleGain(), yaze::emu::DspChannel::keyOn, noiseSample, yaze::emu::DspChannel::pitch, yaze::emu::DspChannel::pitchCounter, ram, reset, yaze::emu::DspChannel::sampleOut, sampleOutL, sampleOutR, yaze::emu::DspChannel::srcn, and yaze::emu::DspChannel::startDelay.
Referenced by Cycle().

| void yaze::emu::Dsp::HandleNoise | ( | ) |
Definition at line 476 of file dsp.cc.
References CheckCounter(), noiseRate, and noiseSample.
Referenced by Cycle().

| void yaze::emu::Dsp::HandleGain | ( | int | ch | ) |
Definition at line 353 of file dsp.cc.
References yaze::emu::DspChannel::adsrRates, yaze::emu::DspChannel::adsrState, channel, CheckCounter(), yaze::emu::DspChannel::gain, yaze::emu::DspChannel::gainSustainLevel, yaze::emu::DspChannel::gainValue, yaze::emu::DspChannel::preclampGain, yaze::emu::DspChannel::sustainLevel, and yaze::emu::DspChannel::useGain.
Referenced by CycleChannel().

| bool yaze::emu::Dsp::CheckCounter | ( | int | rate | ) |
Definition at line 192 of file dsp.cc.
References counter.
Referenced by HandleGain(), and HandleNoise().
| void yaze::emu::Dsp::DecodeBrr | ( | int | ch | ) |
Definition at line 432 of file dsp.cc.
References aram_, yaze::emu::DspChannel::blockOffset, yaze::emu::DspChannel::brrHeader, yaze::emu::DspChannel::bufferOffset, channel, yaze::emu::DspChannel::decodeBuffer, and yaze::emu::DspChannel::decodeOffset.
Referenced by CycleChannel().
| uint8_t yaze::emu::Dsp::Read | ( | uint8_t | adr | ) |
| void yaze::emu::Dsp::Write | ( | uint8_t | adr, |
| uint8_t | val ) |
Definition at line 487 of file dsp.cc.
References yaze::emu::DspChannel::adsrRates, channel, yaze::emu::DspChannel::directGain, dirPage, echoBufferAdr, echoDelay, yaze::emu::DspChannel::echoEnable, echoVolumeL, echoVolumeR, echoWrites, feedbackVolume, firValues, yaze::emu::DspChannel::gainMode, yaze::emu::DspChannel::gainSustainLevel, yaze::emu::DspChannel::gainValue, yaze::emu::DspChannel::keyOff, yaze::emu::DspChannel::keyOn, masterVolumeL, masterVolumeR, mute, noiseRate, yaze::emu::DspChannel::pitch, yaze::emu::DspChannel::pitchModulation, ram, reset, yaze::emu::DspChannel::srcn, yaze::emu::DspChannel::sustainLevel, yaze::emu::DspChannel::useGain, yaze::emu::DspChannel::useNoise, yaze::emu::DspChannel::volumeL, and yaze::emu::DspChannel::volumeR.
Referenced by yaze::emu::Apu::Write(), and yaze::emu::Apu::WriteToDsp().
| 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().
| void yaze::emu::Dsp::GetSamples | ( | int16_t * | sample_data, |
| int | samples_per_frame, | ||
| bool | pal_timing ) |
Definition at line 722 of file dsp.cc.
References yaze::emu::Cosine, yaze::emu::Cubic, yaze::emu::Gaussian, yaze::emu::Hermite, yaze::emu::InterpolateCosine(), yaze::emu::InterpolateCubic(), yaze::emu::InterpolateHermite(), interpolation_type, lastFrameBoundary, yaze::emu::Linear, and sampleBuffer.
Referenced by yaze::emu::Apu::GetSamples().

| int yaze::emu::Dsp::CopyNativeFrame | ( | int16_t * | sample_data, |
| bool | pal_timing ) |
Definition at line 848 of file dsp.cc.
References lastFrameBoundary, and sampleBuffer.
|
inline |
Definition at line 119 of file dsp.h.
References debug_mute_channels_, and mute.
|
inline |
Definition at line 122 of file dsp.h.
References debug_mute_channels_.
|
inline |
|
inline |
Definition at line 136 of file dsp.h.
References sampleBuffer.
|
inline |
Definition at line 137 of file dsp.h.
References sampleOffset.
| void yaze::emu::Dsp::ResetSampleBuffer | ( | ) |
Definition at line 134 of file dsp.cc.
References lastFrameBoundary, sampleBuffer, and sampleOffset.
|
inline |
Definition at line 144 of file dsp.h.
References lastFrameBoundary.
|
inline |
Definition at line 145 of file dsp.h.
References masterVolumeL.
|
inline |
Definition at line 146 of file dsp.h.
References masterVolumeR.
|
inline |
|
inline |
|
inline |
Definition at line 149 of file dsp.h.
References echoWrites.
|
inline |
| InterpolationType yaze::emu::Dsp::interpolation_type = InterpolationType::Gaussian |
Definition at line 153 of file dsp.h.
Referenced by GetSamples().
|
private |
Definition at line 158 of file dsp.h.
Referenced by CopyNativeFrame(), Cycle(), GetSampleBuffer(), GetSamples(), Reset(), and ResetSampleBuffer().
|
private |
Definition at line 159 of file dsp.h.
Referenced by Cycle(), GetSampleOffset(), NewFrame(), Reset(), and ResetSampleBuffer().
|
private |
Definition at line 161 of file dsp.h.
Referenced by CycleChannel(), GetChannelMute(), and SetChannelMute().
|
private |
Definition at line 163 of file dsp.h.
Referenced by CycleChannel(), DecodeBrr(), and HandleEcho().
|
private |
Definition at line 166 of file dsp.h.
Referenced by CycleChannel(), LoadState(), Read(), Reset(), SaveState(), and Write().
|
private |
Definition at line 168 of file dsp.h.
Referenced by CycleChannel(), DecodeBrr(), GetChannel(), GetSample(), HandleGain(), LoadState(), Reset(), SaveState(), and Write().
|
private |
Definition at line 170 of file dsp.h.
Referenced by CheckCounter(), Cycle(), LoadState(), Reset(), and SaveState().
|
private |
Definition at line 171 of file dsp.h.
Referenced by CycleChannel(), LoadState(), Reset(), SaveState(), and Write().
|
private |
Definition at line 172 of file dsp.h.
Referenced by Cycle(), CycleChannel(), LoadState(), Reset(), and SaveState().
|
private |
Definition at line 173 of file dsp.h.
Referenced by Cycle(), IsMuted(), LoadState(), Reset(), SaveState(), SetChannelMute(), and Write().
|
private |
Definition at line 174 of file dsp.h.
Referenced by CycleChannel(), IsReset(), LoadState(), Reset(), SaveState(), and Write().
|
private |
Definition at line 175 of file dsp.h.
Referenced by GetMasterVolumeL(), HandleEcho(), LoadState(), Reset(), SaveState(), and Write().
|
private |
Definition at line 176 of file dsp.h.
Referenced by GetMasterVolumeR(), HandleEcho(), LoadState(), Reset(), SaveState(), and Write().
|
private |
Definition at line 178 of file dsp.h.
Referenced by Cycle(), CycleChannel(), HandleEcho(), LoadState(), Reset(), and SaveState().
|
private |
Definition at line 179 of file dsp.h.
Referenced by Cycle(), CycleChannel(), HandleEcho(), LoadState(), Reset(), and SaveState().
|
private |
Definition at line 180 of file dsp.h.
Referenced by Cycle(), CycleChannel(), HandleEcho(), LoadState(), Reset(), and SaveState().
|
private |
Definition at line 181 of file dsp.h.
Referenced by Cycle(), CycleChannel(), HandleEcho(), LoadState(), Reset(), and SaveState().
|
private |
Definition at line 183 of file dsp.h.
Referenced by CycleChannel(), HandleNoise(), LoadState(), Reset(), and SaveState().
|
private |
Definition at line 184 of file dsp.h.
Referenced by HandleNoise(), LoadState(), Reset(), SaveState(), and Write().
|
private |
Definition at line 186 of file dsp.h.
Referenced by HandleEcho(), IsEchoEnabled(), LoadState(), Reset(), SaveState(), and Write().
|
private |
Definition at line 187 of file dsp.h.
Referenced by HandleEcho(), LoadState(), Reset(), SaveState(), and Write().
|
private |
Definition at line 188 of file dsp.h.
Referenced by HandleEcho(), LoadState(), Reset(), SaveState(), and Write().
|
private |
Definition at line 189 of file dsp.h.
Referenced by HandleEcho(), LoadState(), Reset(), SaveState(), and Write().
|
private |
Definition at line 190 of file dsp.h.
Referenced by HandleEcho(), LoadState(), Reset(), SaveState(), and Write().
|
private |
Definition at line 191 of file dsp.h.
Referenced by GetEchoDelay(), HandleEcho(), LoadState(), Reset(), SaveState(), and Write().
|
private |
Definition at line 192 of file dsp.h.
Referenced by HandleEcho(), LoadState(), Reset(), and SaveState().
|
private |
Definition at line 193 of file dsp.h.
Referenced by HandleEcho(), LoadState(), Reset(), and SaveState().
|
private |
Definition at line 194 of file dsp.h.
Referenced by HandleEcho(), LoadState(), Reset(), and SaveState().
|
private |
Definition at line 195 of file dsp.h.
Referenced by HandleEcho(), LoadState(), Reset(), SaveState(), and Write().
|
private |
Definition at line 196 of file dsp.h.
Referenced by HandleEcho(), LoadState(), Reset(), and SaveState().
|
private |
Definition at line 197 of file dsp.h.
Referenced by HandleEcho(), LoadState(), Reset(), and SaveState().
|
private |
Definition at line 198 of file dsp.h.
Referenced by CopyNativeFrame(), GetFrameBoundary(), GetSamples(), LoadState(), NewFrame(), Reset(), ResetSampleBuffer(), and SaveState().