DSP.hpp
Go to the documentation of this file.
//
// Created by Melefo on 28/01/2020.
//
#ifndef COMSQUARE_DSP_HPP
#define COMSQUARE_DSP_HPP
#include <cstdint>
#include <SFML/Audio.hpp>
#include "../Memory/IMemory.hpp"
namespace ComSquare::APU::DSP
{
struct Registers {
uint8_t volL[8];
uint8_t volR[8];
uint8_t pitchL[8];
uint8_t pitchH[8];
uint8_t srcn[8];
uint8_t adsr1[8];
uint8_t adsr2[8];
uint8_t gain[8];
uint8_t envx[8];
uint8_t outx[8];
uint8_t mvolL;
uint8_t mvolR;
uint8_t evolL;
uint8_t evolR;
union {
struct {
bool kon7 : 1;
bool kon6 : 1;
bool kon5 : 1;
bool kon4 : 1;
bool kon3 : 1;
bool kon2 : 1;
bool kon1 : 1;
bool kon0 : 1;
};
uint8_t kon;
};
union {
struct {
bool kof7 : 1;
bool kof6 : 1;
bool kof5 : 1;
bool kof4 : 1;
bool kof3 : 1;
bool kof2 : 1;
bool kof1 : 1;
bool kof0 : 1;
};
uint8_t kof;
};
uint8_t flg;
union {
struct {
bool endx7 : 1;
bool endx6 : 1;
bool endx5 : 1;
bool endx4 : 1;
bool endx3 : 1;
bool endx2 : 1;
bool endx1 : 1;
bool endx0 : 1;
};
uint8_t endx;
};
uint8_t efb;
uint8_t unused;
union {
struct {
bool pmon7 : 1;
bool pmon6 : 1;
bool pmon5 : 1;
bool pmon4 : 1;
bool pmon3 : 1;
bool pmon2 : 1;
bool pmon1 : 1;
bool __ : 1;
};
uint8_t pmon;
};
union {
struct {
bool non7 : 1;
bool non6 : 1;
bool non5 : 1;
bool non4 : 1;
bool non3 : 1;
bool non2 : 1;
bool non1 : 1;
bool non0 : 1;
};
uint8_t non;
};
union {
struct {
bool eon7 : 1;
bool eon6 : 1;
bool eon5 : 1;
bool eon4 : 1;
bool eon3 : 1;
bool eon2 : 1;
bool eon1 : 1;
bool eon0 : 1;
};
uint8_t eon;
};
uint8_t dir;
uint8_t esa;
uint8_t edl;
uint8_t coeff[8];
};
class DSP : public Memory::IMemory {
private:
Registers _registers{};
sf::Sound _channels[8];
sf::SoundBuffer _soundBuffer;
public:
explicit DSP();
uint8_t read(uint24_t addr) override;
void write(uint24_t addr, uint8_t data) override;
};
}
#endif //COMSQUARE_DSP_HPP
ComSquare::APU::DSP::DSP::_registers
Registers _registers
All registers of the DSP.
Definition: DSP.hpp:160
ComSquare::APU::DSP::Registers::kof6
bool kof6
Definition: DSP.hpp:68
ComSquare::APU::DSP::Registers::flg
uint8_t flg
Flags register.
Definition: DSP.hpp:80
ComSquare::APU::DSP::Registers::eon5
bool eon5
Definition: DSP.hpp:137
ComSquare::APU::DSP::Registers::mvolL
uint8_t mvolL
Left output of the Main Volume register.
Definition: DSP.hpp:41
ComSquare::APU::DSP::Registers::kof3
bool kof3
Definition: DSP.hpp:71
ComSquare::APU::DSP::Registers::kon6
bool kon6
Definition: DSP.hpp:54
ComSquare::APU::DSP::Registers::gain
uint8_t gain[8]
Gain register.
Definition: DSP.hpp:34
ComSquare::APU::DSP::Registers::pitchL
uint8_t pitchL[8]
Lower 8 bits of pitch register.
Definition: DSP.hpp:22
ComSquare::APU::DSP::Registers::non3
bool non3
Definition: DSP.hpp:125
ComSquare::APU::DSP::Registers::adsr1
uint8_t adsr1[8]
Envelope register.
Definition: DSP.hpp:30
ComSquare::APU::DSP::Registers::eon6
bool eon6
Definition: DSP.hpp:136
ComSquare::APU::DSP::DSP::read
uint8_t read(uint24_t addr) override
Read from the internal DSP register.
Definition: DSP.cpp:19
ComSquare::APU::DSP::Registers::pmon7
bool pmon7
Definition: DSP.hpp:106
ComSquare::APU::DSP::Registers::non1
bool non1
Definition: DSP.hpp:127
ComSquare::APU::DSP::Registers::non5
bool non5
Definition: DSP.hpp:123
ComSquare::APU::DSP::Registers::volL
uint8_t volL[8]
Left channel volume register.
Definition: DSP.hpp:17
ComSquare::APU::DSP::Registers::kof2
bool kof2
Definition: DSP.hpp:72
ComSquare::APU::DSP::Registers::eon1
bool eon1
Definition: DSP.hpp:141
ComSquare::APU::DSP::Registers::pmon
uint8_t pmon
Definition: DSP.hpp:115
ComSquare::APU::DSP::Registers::endx7
bool endx7
Definition: DSP.hpp:85
ComSquare::APU::DSP::Registers::evolR
uint8_t evolR
Right output of the Echo Volume register.
Definition: DSP.hpp:48
ComSquare::APU::DSP::Registers::pmon1
bool pmon1
Definition: DSP.hpp:112
ComSquare::APU::DSP::Registers::kof7
bool kof7
Definition: DSP.hpp:67
ComSquare::APU::DSP::Registers::endx1
bool endx1
Definition: DSP.hpp:91
ComSquare::APU::DSP::Registers::envx
uint8_t envx[8]
Envelope value register.
Definition: DSP.hpp:36
ComSquare::APU::DSP::Registers::pmon3
bool pmon3
Definition: DSP.hpp:110
ComSquare::APU::DSP::Registers::outx
uint8_t outx[8]
Wave height register.
Definition: DSP.hpp:38
ComSquare::APU::DSP::Registers::kon5
bool kon5
Definition: DSP.hpp:55
uint24_t
unsigned uint24_t
Definition: Ints.hpp:8
ComSquare::APU::DSP::Registers::kon3
bool kon3
Definition: DSP.hpp:57
ComSquare::APU::DSP::Registers::endx0
bool endx0
Definition: DSP.hpp:92
ComSquare::APU::DSP::Registers::non4
bool non4
Definition: DSP.hpp:124
ComSquare::APU::DSP::Registers::__
bool __
Definition: DSP.hpp:113
ComSquare::Memory::IMemory
Common interface implemented by all components mapping memory.
Definition: IMemory.hpp:16
ComSquare::APU::DSP::Registers::non
uint8_t non
Definition: DSP.hpp:130
ComSquare::APU::DSP::Registers::kon4
bool kon4
Definition: DSP.hpp:56
ComSquare::APU::DSP::Registers::kof1
bool kof1
Definition: DSP.hpp:73
ComSquare::APU::DSP::Registers::esa
uint8_t esa
Echo data start register.
Definition: DSP.hpp:150
ComSquare::APU::DSP::Registers::non2
bool non2
Definition: DSP.hpp:126
ComSquare::APU::DSP::Registers::pmon4
bool pmon4
Definition: DSP.hpp:109
ComSquare::APU::DSP::DSP::write
void write(uint24_t addr, uint8_t data) override
Write data to the internal DSP register.
Definition: DSP.cpp:235
ComSquare::APU::DSP::Registers::eon
uint8_t eon
Definition: DSP.hpp:144
ComSquare::APU::DSP::Registers::endx
uint8_t endx
Definition: DSP.hpp:94
ComSquare::APU::DSP::Registers::mvolR
uint8_t mvolR
Right output of the Main Volume register.
Definition: DSP.hpp:43
ComSquare::APU::DSP::Registers::efb
uint8_t efb
Echo feedback register.
Definition: DSP.hpp:98
ComSquare::APU::DSP::Registers::srcn
uint8_t srcn[8]
Source number register.
Definition: DSP.hpp:27
ComSquare::APU::DSP::Registers::kof5
bool kof5
Definition: DSP.hpp:69
ComSquare::APU::DSP::Registers::kof0
bool kof0
Definition: DSP.hpp:74
ComSquare::APU::DSP::Registers::pitchH
uint8_t pitchH[8]
Higher 8 bits of pitch register.
Definition: DSP.hpp:24
ComSquare::APU::DSP::Registers::non7
bool non7
Definition: DSP.hpp:121
ComSquare::APU::DSP::Registers::eon0
bool eon0
Definition: DSP.hpp:142
ComSquare::APU::DSP::Registers
All the registers of the DSP.
Definition: DSP.hpp:15
ComSquare::APU::DSP::Registers::endx2
bool endx2
Definition: DSP.hpp:90
ComSquare::APU::DSP::Registers::adsr2
uint8_t adsr2[8]
Envelope controllers register.
Definition: DSP.hpp:32
ComSquare::APU::DSP::Registers::non0
bool non0
Definition: DSP.hpp:128
ComSquare::APU::DSP::Registers::pmon6
bool pmon6
Definition: DSP.hpp:107
ComSquare::APU::DSP::Registers::unused
uint8_t unused
Not used register.
Definition: DSP.hpp:101
ComSquare::APU::DSP::Registers::endx5
bool endx5
Definition: DSP.hpp:87
ComSquare::APU::DSP::DSP::_soundBuffer
sf::SoundBuffer _soundBuffer
A buffer containing current wave.
Definition: DSP.hpp:166
ComSquare::APU::DSP::Registers::kon0
bool kon0
Definition: DSP.hpp:60
ComSquare::APU::DSP::DSP::_channels
sf::Sound _channels[8]
8x channels of sample used to make sound
Definition: DSP.hpp:163
ComSquare::APU::DSP::Registers::kon
uint8_t kon
Definition: DSP.hpp:62
ComSquare::APU::DSP::Registers::eon7
bool eon7
Definition: DSP.hpp:135
ComSquare::APU::DSP::Registers::volR
uint8_t volR[8]
Left channel volume register.
Definition: DSP.hpp:19
ComSquare::APU::DSP::Registers::endx4
bool endx4
Definition: DSP.hpp:88
ComSquare::APU::DSP::DSP
Definition: DSP.hpp:157
ComSquare::APU::DSP::Registers::coeff
uint8_t coeff[8]
Echo FIR filter coefficients.
Definition: DSP.hpp:154
ComSquare::APU::DSP::Registers::non6
bool non6
Definition: DSP.hpp:122
ComSquare::APU::DSP::Registers::endx3
bool endx3
Definition: DSP.hpp:89
ComSquare::APU::DSP::Registers::kon1
bool kon1
Definition: DSP.hpp:59
ComSquare::APU::DSP::Registers::pmon2
bool pmon2
Definition: DSP.hpp:111
ComSquare::APU::DSP::Registers::kon2
bool kon2
Definition: DSP.hpp:58
ComSquare::APU::DSP::Registers::endx6
bool endx6
Definition: DSP.hpp:86
ComSquare::APU::DSP::Registers::eon4
bool eon4
Definition: DSP.hpp:138
ComSquare::APU::DSP::Registers::kof4
bool kof4
Definition: DSP.hpp:70
ComSquare::APU::DSP
Definition: DSP.cpp:8
ComSquare::APU::DSP::DSP::DSP
DSP()
Definition: DSP.cpp:10
ComSquare::APU::DSP::Registers::evolL
uint8_t evolL
Left output of the Echo Volume register.
Definition: DSP.hpp:46
ComSquare::APU::DSP::Registers::pmon5
bool pmon5
Definition: DSP.hpp:108
ComSquare::APU::DSP::Registers::eon2
bool eon2
Definition: DSP.hpp:140
ComSquare::APU::DSP::Registers::edl
uint8_t edl
Echo delay size register.
Definition: DSP.hpp:152
ComSquare::APU::DSP::Registers::eon3
bool eon3
Definition: DSP.hpp:139
ComSquare::APU::DSP::Registers::kof
uint8_t kof
Definition: DSP.hpp:76
ComSquare::APU::DSP::Registers::dir
uint8_t dir
Source Directory offset register.
Definition: DSP.hpp:147
ComSquare::APU::DSP::Registers::kon7
bool kon7
Definition: DSP.hpp:53