diff --git a/CMakeLists.txt b/CMakeLists.txt index fa72c08..8d783ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,9 @@ add_executable(unit_tests target_link_libraries(unit_tests criterion -lgcov) target_compile_options(unit_tests PUBLIC -fprofile-arcs -ftest-coverage) +#include SFML +add_link_options(-lsfml-graphics -lsfml-window -lsfml-audio -lsfml-network -lsfml-system) + # make app add_executable(ComSquare main.cpp diff --git a/sources/APU/APU.hpp b/sources/APU/APU.hpp index 6b587b1..e6a6fda 100644 --- a/sources/APU/APU.hpp +++ b/sources/APU/APU.hpp @@ -106,9 +106,9 @@ namespace ComSquare::APU class APU : public Memory::IMemory { private: //! @brief All the registers of the APU CPU - Registers _registers; + Registers _registers{}; //! @brief Internal registers of the CPU (accessible from the bus via addr $4200 to $421F). - InternalRegisters _internalRegisters; + InternalRegisters _internalRegisters{}; //! @brief The DSP component used to produce sound std::shared_ptr _dsp; diff --git a/sources/DSP/DSP.cpp b/sources/DSP/DSP.cpp index bd04cb9..a17c35a 100644 --- a/sources/DSP/DSP.cpp +++ b/sources/DSP/DSP.cpp @@ -8,7 +8,13 @@ namespace ComSquare::APU::DSP { DSP::DSP() - { } + { + for (auto & _channel : this->_channels) { + _channel.setBuffer(this->_soundBuffer); + _channel.setLoop(true); + _channel.play(); + } + } uint8_t DSP::read(uint24_t addr) { diff --git a/sources/DSP/DSP.hpp b/sources/DSP/DSP.hpp index 24bab67..faab2bd 100644 --- a/sources/DSP/DSP.hpp +++ b/sources/DSP/DSP.hpp @@ -6,6 +6,7 @@ #define COMSQUARE_DSP_HPP #include +#include #include "../Memory/IMemory.hpp" namespace ComSquare::APU::DSP @@ -155,7 +156,14 @@ namespace ComSquare::APU::DSP class DSP : public Memory::IMemory { private: + //! @brief All registers of the DSP Registers _registers{}; + + //! @brief 8x channels of sample used to make sound + sf::Sound _channels[8]; + + //! @brief A buffer containing current wave + sf::SoundBuffer _soundBuffer; public: explicit DSP();