diff --git a/CMakeLists.txt b/CMakeLists.txt index 98cb3d3..3beead4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,4 +75,7 @@ add_executable(ComSquare sources/Memory/IRectangleMemory.hpp sources/DSP/DSP.cpp sources/DSP/DSP.hpp + sources/Renderer/IRenderer.hpp + sources/Renderer/SFRenderer.hpp + sources/Renderer/SFRenderer.cpp ) diff --git a/sources/PPU/PPU.cpp b/sources/PPU/PPU.cpp index 8e788c8..32bd47a 100644 --- a/sources/PPU/PPU.cpp +++ b/sources/PPU/PPU.cpp @@ -8,7 +8,8 @@ namespace ComSquare::PPU { - uint8_t PPU::read(uint24_t addr) { + uint8_t PPU::read(uint24_t addr) + { switch (addr) { case 0x34: return this->mpy.mpyl; @@ -21,7 +22,8 @@ namespace ComSquare::PPU } } - void PPU::write(uint24_t addr, uint8_t data) { + void PPU::write(uint24_t addr, uint8_t data) + { switch (addr) { case 0x00: this->inidisp.raw = data; @@ -68,7 +70,8 @@ namespace ComSquare::PPU } } - void PPU::update(int cycles) { - + void PPU::update(int cycles) + { + (void)cycles; } } \ No newline at end of file diff --git a/sources/Renderer/IRenderer.hpp b/sources/Renderer/IRenderer.hpp new file mode 100644 index 0000000..448043d --- /dev/null +++ b/sources/Renderer/IRenderer.hpp @@ -0,0 +1,25 @@ +// +// Created by cbihan on 1/30/20. +// + +#ifndef COMSQUARE_IRENDERER_HPP +#define COMSQUARE_IRENDERER_HPP + +#include + +namespace ComSquare::Renderer +{ + class IRenderer { + public: + //! @brief Set a new name to the window, if there is already a name it will be overwrite + virtual void setWindowName(std::string) = 0; + //! @brief Tells to the program if the window has been closed, and therefore if he should stop + bool shouldExit; + //! @brief Render the buffer to the window + virtual void drawScreen() = 0; + //! @brief Set a pixel to the coordinates x, y with the color rgba + virtual void putPixel(int x, int y, uint8_t rgba) = 0; + }; +} + +#endif //COMSQUARE_IRENDERER_HPP diff --git a/sources/Renderer/SFRenderer.cpp b/sources/Renderer/SFRenderer.cpp new file mode 100644 index 0000000..ec6133d --- /dev/null +++ b/sources/Renderer/SFRenderer.cpp @@ -0,0 +1,25 @@ +// +// Created by cbihan on 1/30/20. +// + +#include "SFRenderer.hpp" + +namespace ComSquare::Renderer +{ + void SFRenderer::setWindowName(std::string) + { + + } + + void SFRenderer::drawScreen() + { + + } + + void SFRenderer::putPixel(int x, int y, uint8_t rgba) + { + (void) x; + (void) y; + (void) rgba; + } +} diff --git a/sources/Renderer/SFRenderer.hpp b/sources/Renderer/SFRenderer.hpp new file mode 100644 index 0000000..772fc77 --- /dev/null +++ b/sources/Renderer/SFRenderer.hpp @@ -0,0 +1,32 @@ +// +// Created by cbihan on 1/30/20. +// + +#ifndef COMSQUARE_SFRENDERER_HPP +#define COMSQUARE_SFRENDERER_HPP + +#include "IRenderer.hpp" +#include +#include +#include +#include +#include + +namespace ComSquare::Renderer +{ + class SFRenderer : public IRenderer { + public: + //! @brief Set a new name to the window, if there is already a name it will be overwrite. + //! @param A new title for the window. + void setWindowName(std::string) override; + //! @brief Update the screen by printing the buffer. + void drawScreen() override; + //! @brief Add a pixel to the buffer to the coordinates x, y with the color rgba. + //! @param X : horizontal index. + //! @param Y : vertical index. + //! @param rgba : The color of the pixel. + void putPixel(int x, int y, uint8_t rgba) override ; + }; +} + +#endif //COMSQUARE_SFRENDERER_HPP