Added render interface and sfml renderer

This commit is contained in:
Clément Le Bihan
2020-01-30 17:33:47 +01:00
parent f76b47cc3d
commit 76bdee9fb5
5 changed files with 92 additions and 4 deletions

View File

@@ -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
)

View File

@@ -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;
}
}

View File

@@ -0,0 +1,25 @@
//
// Created by cbihan on 1/30/20.
//
#ifndef COMSQUARE_IRENDERER_HPP
#define COMSQUARE_IRENDERER_HPP
#include <string>
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

View File

@@ -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;
}
}

View File

@@ -0,0 +1,32 @@
//
// Created by cbihan on 1/30/20.
//
#ifndef COMSQUARE_SFRENDERER_HPP
#define COMSQUARE_SFRENDERER_HPP
#include "IRenderer.hpp"
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics//RenderWindow.hpp>
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