mirror of
https://github.com/zoriya/ComSquare.git
synced 2025-12-20 14:15:11 +00:00
Added render interface and sfml renderer
This commit is contained in:
@@ -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
|
||||
)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
25
sources/Renderer/IRenderer.hpp
Normal file
25
sources/Renderer/IRenderer.hpp
Normal 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
|
||||
25
sources/Renderer/SFRenderer.cpp
Normal file
25
sources/Renderer/SFRenderer.cpp
Normal 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;
|
||||
}
|
||||
}
|
||||
32
sources/Renderer/SFRenderer.hpp
Normal file
32
sources/Renderer/SFRenderer.hpp
Normal 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
|
||||
Reference in New Issue
Block a user