diff --git a/sources/APU/DSP/DSP.cpp b/sources/APU/DSP/DSP.cpp index 63bfa2b..5a7133b 100644 --- a/sources/APU/DSP/DSP.cpp +++ b/sources/APU/DSP/DSP.cpp @@ -3,17 +3,16 @@ // #include "DSP.hpp" -#include "../APU.hpp" -#include "../../Exceptions/InvalidAddress.hpp" +#include "APU/APU.hpp" +#include "Exceptions/InvalidAddress.hpp" namespace ComSquare::APU::DSP { - DSP::DSP(Renderer::IRenderer &renderer, - MemoryMap &map) + DSP::DSP(Renderer::IRenderer &renderer, MemoryMap &map) : _state(this->_soundBuffer, this->_soundBuffer.size() / 2), _map(map), _renderer(renderer) - { } + {} uint8_t DSP::read(uint24_t addr) const { @@ -568,196 +567,197 @@ namespace ComSquare::APU::DSP throw InvalidAddress("DSP Registers write", addr); } } + uint8_t DSP::_readRAM(uint24_t addr) { switch (addr) { - case 0x0000 ... 0x00EF: - return this->_map.Page0.read(addr); - case 0x0100 ... 0x01FF: - return this->_map.Page1.read(addr - 0x0100); - case 0x0200 ... 0xFFBF: - return this->_map.Memory.read(addr - 0x200); - case 0xFFC0 ... 0xFFFF: - return this->_map.IPL.read(addr - 0xFFC0); - default: - throw InvalidAddress("DSP read", addr); + case 0x0000 ... 0x00EF: + return this->_map.Page0.read(addr); + case 0x0100 ... 0x01FF: + return this->_map.Page1.read(addr - 0x0100); + case 0x0200 ... 0xFFBF: + return this->_map.Memory.read(addr - 0x200); + case 0xFFC0 ... 0xFFFF: + return this->_map.IPL.read(addr - 0xFFC0); + default: + throw InvalidAddress("DSP read", addr); } } void DSP::_writeRAM(uint24_t addr, uint8_t data) { switch (addr) { - case 0x0000 ... 0x00EF: - this->_map.Page0.write(addr, data); - break; - case 0x0100 ... 0x01FF: - this->_map.Page1.write(addr - 0x0100, data); - break; - case 0x0200 ... 0xFFBF: - this->_map.Memory.write(addr - 0x200, data); - break; - case 0xFFC0 ... 0xFFFF: - this->_map.IPL.write(addr - 0xFFC0, data); - break; - default: - throw InvalidAddress("DSP write", addr); + case 0x0000 ... 0x00EF: + this->_map.Page0.write(addr, data); + break; + case 0x0100 ... 0x01FF: + this->_map.Page1.write(addr - 0x0100, data); + break; + case 0x0200 ... 0xFFBF: + this->_map.Memory.write(addr - 0x200, data); + break; + case 0xFFC0 ... 0xFFFF: + this->_map.IPL.write(addr - 0xFFC0, data); + break; + default: + throw InvalidAddress("DSP write", addr); } } void DSP::update() { switch (this->_state.voice) { - case 0: - this->voice5(this->_voices[0]); - this->voice2(this->_voices[1]); - break; - case 1: - this->voice6(this->_voices[0]); - this->voice3(this->_voices[1]); - break; - case 2: - this->voice7(this->_voices[0]); - this->voice4(this->_voices[1]); - this->voice1(this->_voices[3]); - break; - case 3: - this->voice8(this->_voices[0]); - this->voice5(this->_voices[1]); - this->voice2(this->_voices[2]); - break; - case 4: - this->voice9(this->_voices[0]); - this->voice6(this->_voices[1]); - this->voice3(this->_voices[2]); - break; - case 5: - this->voice7(this->_voices[1]); - this->voice4(this->_voices[2]); - this->voice1(this->_voices[4]); - break; - case 6: - this->voice8(this->_voices[1]); - this->voice5(this->_voices[2]); - this->voice2(this->_voices[3]); - break; - case 7: - this->voice9(this->_voices[1]); - this->voice6(this->_voices[2]); - this->voice3(this->_voices[3]); - break; - case 8: - this->voice7(this->_voices[2]); - this->voice4(this->_voices[3]); - this->voice1(this->_voices[5]); - break; - case 9: - this->voice8(this->_voices[2]); - this->voice5(this->_voices[3]); - this->voice2(this->_voices[4]); - break; - case 10: - this->voice9(this->_voices[2]); - this->voice6(this->_voices[3]); - this->voice3(this->_voices[4]); - break; - case 11: - this->voice7(this->_voices[3]); - this->voice4(this->_voices[4]); - this->voice1(this->_voices[6]); - break; - case 12: - this->voice8(this->_voices[3]); - this->voice5(this->_voices[4]); - this->voice2(this->_voices[5]); - break; - case 13: - this->voice9(this->_voices[3]); - this->voice6(this->_voices[4]); - this->voice3(this->_voices[5]); - break; - case 14: - this->voice7(this->_voices[4]); - this->voice4(this->_voices[5]); - this->voice1(this->_voices[7]); - break; - case 15: - this->voice8(this->_voices[4]); - this->voice5(this->_voices[5]); - this->voice2(this->_voices[6]); - break; - case 16: - this->voice9(this->_voices[4]); - this->voice6(this->_voices[5]); - this->voice3(this->_voices[6]); - break; - case 17: - this->voice1(this->_voices[0]); - this->voice7(this->_voices[5]); - this->voice4(this->_voices[6]); - break; - case 18: - this->voice8(this->_voices[5]); - this->voice5(this->_voices[6]); - this->voice2(this->_voices[7]); - break; - case 19: - this->voice9(this->_voices[5]); - this->voice6(this->_voices[6]); - this->voice3(this->_voices[7]); - break; - case 20: - this->voice1(this->_voices[1]); - this->voice7(this->_voices[6]); - this->voice4(this->_voices[7]); - break; - case 21: - this->voice8(this->_voices[6]); - this->voice5(this->_voices[7]); - this->voice2(this->_voices[0]); - break; - case 22: - this->voice3a(this->_voices[0]); - this->voice9(this->_voices[6]); - this->voice6(this->_voices[7]); - echo22(); - break; - case 23: - this->voice7(this->_voices[7]); - echo23(); - break; - case 24: - this->voice8(this->_voices[7]); - echo24(); - break; - case 25: - this->voice3b(this->_voices[0]); - this->voice9(this->_voices[7]); - echo25(); - break; - case 26: - echo26(); - break; - case 27: - this->misc27(); - this->echo27(); - break; - case 28: - this->misc28(); - this->echo28(); - break; - case 29: - this->misc29(); - this->echo29(); - break; - case 30: - this->misc30(); - this->voice3c(this->_voices[0]); - this->echo30(); - break; - case 31: - this->voice4(this->_voices[0]); - this->voice1(this->_voices[2]); - break; + case 0: + this->voice5(this->_voices[0]); + this->voice2(this->_voices[1]); + break; + case 1: + this->voice6(this->_voices[0]); + this->voice3(this->_voices[1]); + break; + case 2: + this->voice7(this->_voices[0]); + this->voice4(this->_voices[1]); + this->voice1(this->_voices[3]); + break; + case 3: + this->voice8(this->_voices[0]); + this->voice5(this->_voices[1]); + this->voice2(this->_voices[2]); + break; + case 4: + this->voice9(this->_voices[0]); + this->voice6(this->_voices[1]); + this->voice3(this->_voices[2]); + break; + case 5: + this->voice7(this->_voices[1]); + this->voice4(this->_voices[2]); + this->voice1(this->_voices[4]); + break; + case 6: + this->voice8(this->_voices[1]); + this->voice5(this->_voices[2]); + this->voice2(this->_voices[3]); + break; + case 7: + this->voice9(this->_voices[1]); + this->voice6(this->_voices[2]); + this->voice3(this->_voices[3]); + break; + case 8: + this->voice7(this->_voices[2]); + this->voice4(this->_voices[3]); + this->voice1(this->_voices[5]); + break; + case 9: + this->voice8(this->_voices[2]); + this->voice5(this->_voices[3]); + this->voice2(this->_voices[4]); + break; + case 10: + this->voice9(this->_voices[2]); + this->voice6(this->_voices[3]); + this->voice3(this->_voices[4]); + break; + case 11: + this->voice7(this->_voices[3]); + this->voice4(this->_voices[4]); + this->voice1(this->_voices[6]); + break; + case 12: + this->voice8(this->_voices[3]); + this->voice5(this->_voices[4]); + this->voice2(this->_voices[5]); + break; + case 13: + this->voice9(this->_voices[3]); + this->voice6(this->_voices[4]); + this->voice3(this->_voices[5]); + break; + case 14: + this->voice7(this->_voices[4]); + this->voice4(this->_voices[5]); + this->voice1(this->_voices[7]); + break; + case 15: + this->voice8(this->_voices[4]); + this->voice5(this->_voices[5]); + this->voice2(this->_voices[6]); + break; + case 16: + this->voice9(this->_voices[4]); + this->voice6(this->_voices[5]); + this->voice3(this->_voices[6]); + break; + case 17: + this->voice1(this->_voices[0]); + this->voice7(this->_voices[5]); + this->voice4(this->_voices[6]); + break; + case 18: + this->voice8(this->_voices[5]); + this->voice5(this->_voices[6]); + this->voice2(this->_voices[7]); + break; + case 19: + this->voice9(this->_voices[5]); + this->voice6(this->_voices[6]); + this->voice3(this->_voices[7]); + break; + case 20: + this->voice1(this->_voices[1]); + this->voice7(this->_voices[6]); + this->voice4(this->_voices[7]); + break; + case 21: + this->voice8(this->_voices[6]); + this->voice5(this->_voices[7]); + this->voice2(this->_voices[0]); + break; + case 22: + this->voice3a(this->_voices[0]); + this->voice9(this->_voices[6]); + this->voice6(this->_voices[7]); + echo22(); + break; + case 23: + this->voice7(this->_voices[7]); + echo23(); + break; + case 24: + this->voice8(this->_voices[7]); + echo24(); + break; + case 25: + this->voice3b(this->_voices[0]); + this->voice9(this->_voices[7]); + echo25(); + break; + case 26: + echo26(); + break; + case 27: + this->misc27(); + this->echo27(); + break; + case 28: + this->misc28(); + this->echo28(); + break; + case 29: + this->misc29(); + this->echo29(); + break; + case 30: + this->misc30(); + this->voice3c(this->_voices[0]); + this->echo30(); + break; + case 31: + this->voice4(this->_voices[0]); + this->voice1(this->_voices[2]); + break; } this->_state.voice = (this->_state.voice + 1) % 32; int32_t samples = this->getSamplesCount(); diff --git a/sources/APU/DSP/DSP.hpp b/sources/APU/DSP/DSP.hpp index 8e8e2e3..f3445d2 100644 --- a/sources/APU/DSP/DSP.hpp +++ b/sources/APU/DSP/DSP.hpp @@ -270,6 +270,8 @@ namespace ComSquare::APU::DSP 1299, 1300, 1300, 1301, 1302, 1302, 1303, 1303, 1303, 1304, 1304, 1304, 1304, 1304, 1305, 1305 }; + //! @brief Buffer containing samples to be played + std::array _soundBuffer = {}; //! @brief 8x voices of sample used to make sound std::array _voices {}; Master _master {}; @@ -330,8 +332,6 @@ namespace ComSquare::APU::DSP //! @brief Renderer used to play sounds Renderer::IRenderer &_renderer; - //! @brief Buffer containing samples to be played - std::array _soundBuffer = {}; //! @brief Read inside APU RAM uint8_t _readRAM(uint24_t addr); diff --git a/sources/APU/DSP/Voice.cpp b/sources/APU/DSP/Voice.cpp index 324e07e..28353d2 100644 --- a/sources/APU/DSP/Voice.cpp +++ b/sources/APU/DSP/Voice.cpp @@ -3,7 +3,7 @@ // #include "DSP.hpp" -#include "../APU.hpp" +#include "APU/APU.hpp" #include namespace ComSquare::APU::DSP diff --git a/sources/APU/IPL/IPL.cpp b/sources/APU/IPL/IPL.cpp index 99fd05e..bf6de72 100644 --- a/sources/APU/IPL/IPL.cpp +++ b/sources/APU/IPL/IPL.cpp @@ -3,8 +3,7 @@ // #include "IPL.hpp" - -#include "../../Exceptions/InvalidAddress.hpp" +#include "Exceptions/InvalidAddress.hpp" #include namespace ComSquare::APU::IPL diff --git a/sources/APU/Instructions/16bitArithmetic.cpp b/sources/APU/Instructions/16bitArithmetic.cpp index 9ca5c61..3a3f775 100644 --- a/sources/APU/Instructions/16bitArithmetic.cpp +++ b/sources/APU/Instructions/16bitArithmetic.cpp @@ -2,7 +2,7 @@ // Created by Melefo on 25/02/2020. // -#include "../APU.hpp" +#include "APU/APU.hpp" namespace ComSquare::APU { diff --git a/sources/APU/Instructions/16bitDataTransmission.cpp b/sources/APU/Instructions/16bitDataTransmission.cpp index 5a28ce6..cace781 100644 --- a/sources/APU/Instructions/16bitDataTransmission.cpp +++ b/sources/APU/Instructions/16bitDataTransmission.cpp @@ -2,7 +2,7 @@ // Created by Melefo on 25/02/2020. // -#include "../APU.hpp" +#include "APU/APU.hpp" namespace ComSquare::APU { diff --git a/sources/APU/Instructions/8bitArithmetic.cpp b/sources/APU/Instructions/8bitArithmetic.cpp index 2010d99..eeaec40 100644 --- a/sources/APU/Instructions/8bitArithmetic.cpp +++ b/sources/APU/Instructions/8bitArithmetic.cpp @@ -2,7 +2,7 @@ // Created by Melefo on 27/02/2020. // -#include "../APU.hpp" +#include "APU/APU.hpp" namespace ComSquare::APU { diff --git a/sources/APU/Instructions/8bitDataTransmission.cpp b/sources/APU/Instructions/8bitDataTransmission.cpp index 7e08122..e4f2c56 100644 --- a/sources/APU/Instructions/8bitDataTransmission.cpp +++ b/sources/APU/Instructions/8bitDataTransmission.cpp @@ -2,8 +2,8 @@ // Created by Melefo on 27/02/2020. // -#include "../APU.hpp" -#include "../../Utility/Utility.hpp" +#include "APU/APU.hpp" +#include "Utility/Utility.hpp" namespace ComSquare::APU { diff --git a/sources/APU/Instructions/8bitIncrementDecrement.cpp b/sources/APU/Instructions/8bitIncrementDecrement.cpp index e4169a8..c517bde 100644 --- a/sources/APU/Instructions/8bitIncrementDecrement.cpp +++ b/sources/APU/Instructions/8bitIncrementDecrement.cpp @@ -2,7 +2,7 @@ // Created by Melefo on 26/02/2020. // -#include "../APU.hpp" +#include "APU/APU.hpp" namespace ComSquare::APU { diff --git a/sources/APU/Instructions/8bitLogical.cpp b/sources/APU/Instructions/8bitLogical.cpp index ed4a9dd..86ece57 100644 --- a/sources/APU/Instructions/8bitLogical.cpp +++ b/sources/APU/Instructions/8bitLogical.cpp @@ -2,7 +2,7 @@ // Created by Melefo on 26/02/2020. // -#include "../APU.hpp" +#include "APU/APU.hpp" namespace ComSquare::APU { diff --git a/sources/APU/Instructions/8bitShiftRotation.cpp b/sources/APU/Instructions/8bitShiftRotation.cpp index 1aece45..01e3800 100644 --- a/sources/APU/Instructions/8bitShiftRotation.cpp +++ b/sources/APU/Instructions/8bitShiftRotation.cpp @@ -2,7 +2,7 @@ // Created by Melefo on 25/02/2020. // -#include "../APU.hpp" +#include "APU/APU.hpp" namespace ComSquare::APU { diff --git a/sources/APU/Instructions/Bit.cpp b/sources/APU/Instructions/Bit.cpp index 74f172a..0614091 100644 --- a/sources/APU/Instructions/Bit.cpp +++ b/sources/APU/Instructions/Bit.cpp @@ -2,8 +2,8 @@ // Created by Melefo on 12/02/2020. // -#include "../APU.hpp" -#include "../../Utility/Utility.hpp" +#include "APU/APU.hpp" +#include "Utility/Utility.hpp" namespace ComSquare::APU { diff --git a/sources/APU/Instructions/MultiplicationDivision.cpp b/sources/APU/Instructions/MultiplicationDivision.cpp index b43a08c..5e298ba 100644 --- a/sources/APU/Instructions/MultiplicationDivision.cpp +++ b/sources/APU/Instructions/MultiplicationDivision.cpp @@ -2,7 +2,7 @@ // Created by Melefo on 25/02/2020. // -#include "../APU.hpp" +#include "APU/APU.hpp" namespace ComSquare::APU { diff --git a/sources/APU/Instructions/ProgramFlow.cpp b/sources/APU/Instructions/ProgramFlow.cpp index 343b30d..a4815af 100644 --- a/sources/APU/Instructions/ProgramFlow.cpp +++ b/sources/APU/Instructions/ProgramFlow.cpp @@ -2,7 +2,7 @@ // Created by Melefo on 21/02/2020. // -#include "../APU.hpp" +#include "APU/APU.hpp" namespace ComSquare::APU { diff --git a/sources/APU/Instructions/ProgramStatusWord.cpp b/sources/APU/Instructions/ProgramStatusWord.cpp index 0612756..57555f5 100644 --- a/sources/APU/Instructions/ProgramStatusWord.cpp +++ b/sources/APU/Instructions/ProgramStatusWord.cpp @@ -2,7 +2,7 @@ // Created by Melefo on 11/02/2020. // -#include "../APU.hpp" +#include "APU/APU.hpp" namespace ComSquare::APU { diff --git a/sources/APU/Instructions/Stack.cpp b/sources/APU/Instructions/Stack.cpp index 65ab315..dd17619 100644 --- a/sources/APU/Instructions/Stack.cpp +++ b/sources/APU/Instructions/Stack.cpp @@ -2,7 +2,7 @@ // Created by Melefo on 21/02/2020. // -#include "../APU.hpp" +#include "APU/APU.hpp" namespace ComSquare::APU { diff --git a/sources/APU/Instructions/Standbys.cpp b/sources/APU/Instructions/Standbys.cpp index 151cd1a..99d28f2 100644 --- a/sources/APU/Instructions/Standbys.cpp +++ b/sources/APU/Instructions/Standbys.cpp @@ -2,7 +2,7 @@ // Created by Melefo on 11/02/2020. // -#include "../APU.hpp" +#include "APU/APU.hpp" namespace ComSquare::APU { diff --git a/sources/APU/Instructions/Subroutine.cpp b/sources/APU/Instructions/Subroutine.cpp index d35a6b5..5a70a13 100644 --- a/sources/APU/Instructions/Subroutine.cpp +++ b/sources/APU/Instructions/Subroutine.cpp @@ -2,8 +2,8 @@ // Created by Melefo on 21/02/2020. // -#include "../APU.hpp" -#include "../../Utility/Utility.hpp" +#include "APU/APU.hpp" +#include "Utility/Utility.hpp" namespace ComSquare::APU { diff --git a/sources/APU/Operand.cpp b/sources/APU/Operand.cpp index 4874ec5..567c3e1 100644 --- a/sources/APU/Operand.cpp +++ b/sources/APU/Operand.cpp @@ -2,7 +2,7 @@ // Created by Melefo on 24/02/2020. // -#include "../Models/Ints.hpp" +#include "Models/Ints.hpp" #include "APU.hpp" namespace ComSquare::APU diff --git a/sources/CPU/AddressingModes.cpp b/sources/CPU/AddressingModes.cpp index 698b68b..179ff5e 100644 --- a/sources/CPU/AddressingModes.cpp +++ b/sources/CPU/AddressingModes.cpp @@ -2,7 +2,7 @@ // Created by anonymus-raccoon on 3/20/20. // -#include "../Models/Ints.hpp" +#include "Models/Ints.hpp" #include "CPU.hpp" namespace ComSquare::CPU diff --git a/sources/CPU/Instructions/BitsInstructions.cpp b/sources/CPU/Instructions/BitsInstructions.cpp index 6664282..1aaf9ba 100644 --- a/sources/CPU/Instructions/BitsInstructions.cpp +++ b/sources/CPU/Instructions/BitsInstructions.cpp @@ -3,8 +3,8 @@ // #include -#include "../../Models/Ints.hpp" -#include "../CPU.hpp" +#include "Models/Ints.hpp" +#include "CPU/CPU.hpp" namespace ComSquare::CPU { diff --git a/sources/CPU/Instructions/InternalInstruction.cpp b/sources/CPU/Instructions/InternalInstruction.cpp index 1ce1df9..8975f75 100644 --- a/sources/CPU/Instructions/InternalInstruction.cpp +++ b/sources/CPU/Instructions/InternalInstruction.cpp @@ -2,7 +2,7 @@ // Created by anonymus-raccoon on 2/13/20. // -#include "../CPU.hpp" +#include "CPU/CPU.hpp" namespace ComSquare::CPU { diff --git a/sources/CPU/Instructions/MathematicalOperations.cpp b/sources/CPU/Instructions/MathematicalOperations.cpp index ea5ce93..9ad3657 100644 --- a/sources/CPU/Instructions/MathematicalOperations.cpp +++ b/sources/CPU/Instructions/MathematicalOperations.cpp @@ -3,7 +3,7 @@ // #include -#include "../CPU.hpp" +#include "CPU/CPU.hpp" namespace ComSquare::CPU { diff --git a/sources/CPU/Instructions/MemoryInstructions.cpp b/sources/CPU/Instructions/MemoryInstructions.cpp index 737f114..012f9b9 100644 --- a/sources/CPU/Instructions/MemoryInstructions.cpp +++ b/sources/CPU/Instructions/MemoryInstructions.cpp @@ -2,7 +2,7 @@ // Created by anonymus-raccoon on 2/13/20. // -#include "../CPU.hpp" +#include "CPU/CPU.hpp" namespace ComSquare::CPU { diff --git a/sources/CPU/Instructions/TransferRegisters.cpp b/sources/CPU/Instructions/TransferRegisters.cpp index e0ecb55..9896ac2 100644 --- a/sources/CPU/Instructions/TransferRegisters.cpp +++ b/sources/CPU/Instructions/TransferRegisters.cpp @@ -3,7 +3,7 @@ // #include -#include "../CPU.hpp" +#include "CPU/CPU.hpp" namespace ComSquare::CPU { diff --git a/sources/Ram/Ram.cpp b/sources/Ram/Ram.cpp index da1b17f..974111e 100644 --- a/sources/Ram/Ram.cpp +++ b/sources/Ram/Ram.cpp @@ -5,7 +5,7 @@ #include #include #include "Ram.hpp" -#include "../Exceptions/InvalidAddress.hpp" +#include "Exceptions/InvalidAddress.hpp" namespace ComSquare::Ram {