mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-05-23 06:48:25 +00:00
Update C++ to v20
Using span inside renderers
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
# set the project name
|
||||
project(ComSquare)
|
||||
|
||||
+1
-1
@@ -728,7 +728,7 @@ namespace ComSquare::APU
|
||||
this->_dsp.update();
|
||||
samples = this->_dsp.getSamplesCount();
|
||||
if (samples > 0)
|
||||
this->_renderer.playAudio(this->_soundBuffer.data(), samples / 2);
|
||||
this->_renderer.playAudio(std::span{this->_soundBuffer}, samples / 2);
|
||||
}
|
||||
|
||||
void APU::_setNZflags(uint8_t value)
|
||||
|
||||
@@ -55,11 +55,6 @@ namespace ComSquare::CPU
|
||||
std::string name = "";
|
||||
AddressingMode addressingMode = Implied;
|
||||
int size = 0;
|
||||
|
||||
Instruction() = default;
|
||||
Instruction(const Instruction &) = default;
|
||||
Instruction &operator=(const Instruction &) = default;
|
||||
~Instruction() = default;
|
||||
};
|
||||
}
|
||||
#endif //COMSQUARE_INSTRUCTION_HPP
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#define COMSQUARE_IRENDERER_HPP
|
||||
|
||||
#include <string>
|
||||
#include <span>
|
||||
|
||||
namespace ComSquare
|
||||
{
|
||||
@@ -34,7 +35,7 @@ namespace ComSquare
|
||||
//! @brief Playing all samples from buffer
|
||||
//! @param samples Buffer containing samples
|
||||
//! @param sampleCount number of samples inside buffer
|
||||
virtual void playAudio(int16_t *samples, uint64_t sampleCount) = 0;
|
||||
virtual void playAudio(std::span<int16_t> samples, uint64_t sampleCount) = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace ComSquare::Renderer
|
||||
(void)rgba;
|
||||
}
|
||||
|
||||
void NoRenderer::playAudio(int16_t *, uint64_t)
|
||||
void NoRenderer::playAudio(std::span<int16_t>, uint64_t)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace ComSquare::Renderer
|
||||
//! @brief Playing all samples from buffer
|
||||
//! @param samples Buffer containing samples
|
||||
//! @param sampleCount number of samples inside buffer
|
||||
void playAudio(int16_t *samples, uint64_t sampleCount) override;
|
||||
void playAudio(std::span<int16_t> samples, uint64_t sampleCount) override;
|
||||
//! @brief Get the inputs from the Window
|
||||
void getEvents();
|
||||
//! @brief Use this function to create the window.
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace ComSquare::Renderer
|
||||
this->_sfWidget->putPixel(y, x, rgba);
|
||||
}
|
||||
|
||||
void QtSFML::playAudio(int16_t *samples, uint64_t sampleCount)
|
||||
void QtSFML::playAudio(std::span<int16_t> samples, uint64_t sampleCount)
|
||||
{
|
||||
this->_sfWidget->playAudio(samples, sampleCount);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace ComSquare::Renderer
|
||||
//! @brief Playing all samples from buffer
|
||||
//! @param samples Buffer containing samples
|
||||
//! @param sampleCount number of samples inside buffer
|
||||
void playAudio(int16_t *samples, uint64_t sampleCount) override;
|
||||
void playAudio(std::span<int16_t> samples, uint64_t sampleCount) override;
|
||||
//! @brief Set a new name to the window, if there is already a name it will be overwrite.
|
||||
//! @param newWindowName new title for the window.
|
||||
void setWindowName(std::string &newWindowName) override;
|
||||
|
||||
@@ -54,9 +54,9 @@ namespace ComSquare::Renderer
|
||||
this->_window.display();
|
||||
}
|
||||
|
||||
void SFRenderer::playAudio(int16_t *samples, uint64_t sampleCount)
|
||||
void SFRenderer::playAudio(std::span<int16_t> samples, uint64_t sampleCount)
|
||||
{
|
||||
this->_soundBuffer.loadFromSamples(samples, sampleCount, 2, 32040);
|
||||
this->_soundBuffer.loadFromSamples(samples.data(), sampleCount, 2, 32040);
|
||||
this->_sound.play();
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace ComSquare::Renderer
|
||||
//! @brief Playing all samples from buffer
|
||||
//! @param samples Buffer containing samples
|
||||
//! @param sampleCount number of samples inside buffer
|
||||
void playAudio(int16_t *samples, uint64_t sampleCount) override;
|
||||
void playAudio(std::span<int16_t> samples, uint64_t sampleCount) override;
|
||||
//! @brief Get the inputs from the Window
|
||||
void getEvents();
|
||||
//! @brief Use this function to create the window.
|
||||
|
||||
Reference in New Issue
Block a user