diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e1a0c7..a15830a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,5 +75,8 @@ 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 sources/Exceptions/InvalidAcction.hpp ) diff --git a/sources/PPU/PPU.cpp b/sources/PPU/PPU.cpp index c8791bd..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; @@ -62,9 +64,14 @@ namespace ComSquare::PPU case 0x0C: this->bg34nba.raw = data; break; - //TODO adding the rest of the registers. ooof ! + //TODO adding the rest of the registers. oaf ! default: throw InvalidAddress("PPU Internal Registers write", addr); } } + + void PPU::update(int cycles) + { + (void)cycles; + } } \ No newline at end of file diff --git a/sources/PPU/PPU.hpp b/sources/PPU/PPU.hpp index 69f9442..a06b449 100644 --- a/sources/PPU/PPU.hpp +++ b/sources/PPU/PPU.hpp @@ -390,6 +390,9 @@ namespace ComSquare::PPU //! @param data The new data to write. //! @throw This function should thrown an InvalidAddress for address that are not mapped to the component. void write(uint24_t addr, uint8_t data) override; + //! @brief Update the PPU of n cycles. + //! @param The number of cycles to update. + void update(int cycles); }; } #endif //COMSQUARE_PPU_HPP 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