From effd70cf1e65ebcb205ba156954ed2224752dde2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Mon, 24 May 2021 00:44:18 +0200 Subject: [PATCH] start to test the implementation of tilerenderer --- sources/Debugger/TileViewer/TileViewer.cpp | 5 +++++ sources/Debugger/TileViewer/TileViewer.hpp | 9 +++++---- sources/PPU/PPU.cpp | 15 ++++++++++----- sources/PPU/PPU.hpp | 13 ++++++++----- sources/SNES.hpp | 2 +- 5 files changed, 29 insertions(+), 15 deletions(-) diff --git a/sources/Debugger/TileViewer/TileViewer.cpp b/sources/Debugger/TileViewer/TileViewer.cpp index 652500e..a4ffc0c 100644 --- a/sources/Debugger/TileViewer/TileViewer.cpp +++ b/sources/Debugger/TileViewer/TileViewer.cpp @@ -139,4 +139,9 @@ namespace ComSquare::Debugger return palette; } + void TileRenderer::setCgram(std::shared_ptr ram) + { + this->_cgram = std::move(ram); + } + } \ No newline at end of file diff --git a/sources/Debugger/TileViewer/TileViewer.hpp b/sources/Debugger/TileViewer/TileViewer.hpp index e0e5f89..63039cb 100644 --- a/sources/Debugger/TileViewer/TileViewer.hpp +++ b/sources/Debugger/TileViewer/TileViewer.hpp @@ -9,9 +9,9 @@ #include #include #include "PPU/PPU.hpp" -#include "ClosableWindow.hpp" +#include "Debugger/ClosableWindow.hpp" #include "Renderer/QtRenderer/QtSFML.hpp" -#include "ui/ui_tileView.h" +#include "../../ui/ui_tileView.h" #include "Ram/Ram.hpp" @@ -24,13 +24,14 @@ namespace ComSquare::Debugger //! @brief cgram to access the colors std::shared_ptr _cgram; //! @brief The bpp to use while rendering - int _bpp, + int _bpp; //! @brief The palette number to use while rendering int _palette; public: //! @brief internal buffer - std::array, 1024> buffer; + std::array, 1024> buffer; void setPalette(int palette); + void setCgram(std::shared_ptr ram); void setBpp(int bpp); void setRam(std::shared_ptr ram); uint8_t getPixelReferenceFromTileRow(uint16_t tileRowAddress, uint8_t pixelIndex); diff --git a/sources/PPU/PPU.cpp b/sources/PPU/PPU.cpp index d015fd1..3315ce3 100644 --- a/sources/PPU/PPU.cpp +++ b/sources/PPU/PPU.cpp @@ -5,10 +5,10 @@ #include #include #include "PPU.hpp" -#include "../Exceptions/NotImplementedException.hpp" -#include "../Exceptions/InvalidAddress.hpp" -#include "../Ram/Ram.hpp" -#include "../Models/Vector2.hpp" +#include "Exceptions/NotImplementedException.hpp" +#include "Exceptions/InvalidAddress.hpp" +#include "Ram/Ram.hpp" +#include "Models/Vector2.hpp" #include namespace ComSquare::PPU @@ -31,6 +31,8 @@ namespace ComSquare::PPU _mainScreen({{{0}}}), _subScreen({{{0}}}) { + this->tileRenderer.setRam(this->vram); + this->tileRenderer.setCgram(this->cgram); this->_registers._isLowByte = true; //colors for the cgram @@ -465,7 +467,10 @@ namespace ComSquare::PPU void PPU::update(unsigned cycles) { (void)cycles; + this->tileRenderer.render(); + this->add_buffer(this->_screen, this->tileRenderer.buffer); + /* this->renderMainAndSubScreen(); this->add_buffer(this->_screen, this->_subScreen); this->add_buffer(this->_screen, this->_mainScreen); @@ -475,7 +480,7 @@ namespace ComSquare::PPU for (unsigned long j = 0; j < this->_screen[i].size(); j++) { this->_renderer.putPixel(j, i, this->_screen[i][j]); } - } + }*/ this->_renderer.drawScreen(); } diff --git a/sources/PPU/PPU.hpp b/sources/PPU/PPU.hpp index af750cc..f52bd36 100644 --- a/sources/PPU/PPU.hpp +++ b/sources/PPU/PPU.hpp @@ -6,13 +6,14 @@ #define COMSQUARE_PPU_HPP #include -#include "../Memory/AMemory.hpp" -#include "../Memory/MemoryBus.hpp" -#include "../Renderer/IRenderer.hpp" -#include "../Ram/Ram.hpp" -#include "../Models/Vector2.hpp" +#include "Memory/AMemory.hpp" +#include "Memory/MemoryBus.hpp" +#include "Renderer/IRenderer.hpp" +#include "Ram/Ram.hpp" +#include "Models/Vector2.hpp" #include "Background.hpp" #include "PPUUtils.hpp" +#include "Debugger/TileViewer/TileViewer.hpp" #define FALLTHROUGH __attribute__((fallthrough)); @@ -631,6 +632,8 @@ namespace ComSquare::PPU Vector2 getBgScroll(int bgNumber) const; //! @brief Allow to look the value of each write register (used by Register debugger) const Registers &getWriteRegisters() const; + + Debugger::TileRenderer tileRenderer; }; //! @brief Transform SNES color code BGR to uint32_t RGB diff --git a/sources/SNES.hpp b/sources/SNES.hpp index 757b0b7..133730e 100644 --- a/sources/SNES.hpp +++ b/sources/SNES.hpp @@ -19,7 +19,7 @@ #include "Debugger/HeaderViewer.hpp" #include "Debugger/CGramDebug.hpp" #include "Debugger/RegisterViewer.hpp" - #include "Debugger/TileViewer.hpp" + #include "Debugger/TileViewer/TileViewer.hpp" #endif namespace ComSquare