start to test the implementation of tilerenderer

This commit is contained in:
Clément Le Bihan
2021-05-24 00:44:18 +02:00
parent 4024b51c9f
commit effd70cf1e
5 changed files with 29 additions and 15 deletions

View File

@@ -139,4 +139,9 @@ namespace ComSquare::Debugger
return palette; return palette;
} }
void TileRenderer::setCgram(std::shared_ptr<Ram::Ram> ram)
{
this->_cgram = std::move(ram);
}
} }

View File

@@ -9,9 +9,9 @@
#include <QMouseEvent> #include <QMouseEvent>
#include <array> #include <array>
#include "PPU/PPU.hpp" #include "PPU/PPU.hpp"
#include "ClosableWindow.hpp" #include "Debugger/ClosableWindow.hpp"
#include "Renderer/QtRenderer/QtSFML.hpp" #include "Renderer/QtRenderer/QtSFML.hpp"
#include "ui/ui_tileView.h" #include "../../ui/ui_tileView.h"
#include "Ram/Ram.hpp" #include "Ram/Ram.hpp"
@@ -24,13 +24,14 @@ namespace ComSquare::Debugger
//! @brief cgram to access the colors //! @brief cgram to access the colors
std::shared_ptr<Ram::Ram> _cgram; std::shared_ptr<Ram::Ram> _cgram;
//! @brief The bpp to use while rendering //! @brief The bpp to use while rendering
int _bpp, int _bpp;
//! @brief The palette number to use while rendering //! @brief The palette number to use while rendering
int _palette; int _palette;
public: public:
//! @brief internal buffer //! @brief internal buffer
std::array<std::array<uint32_t, 500>, 1024> buffer; std::array<std::array<uint32_t, 1024>, 1024> buffer;
void setPalette(int palette); void setPalette(int palette);
void setCgram(std::shared_ptr<Ram::Ram> ram);
void setBpp(int bpp); void setBpp(int bpp);
void setRam(std::shared_ptr<Ram::Ram> ram); void setRam(std::shared_ptr<Ram::Ram> ram);
uint8_t getPixelReferenceFromTileRow(uint16_t tileRowAddress, uint8_t pixelIndex); uint8_t getPixelReferenceFromTileRow(uint16_t tileRowAddress, uint8_t pixelIndex);

View File

@@ -5,10 +5,10 @@
#include <iostream> #include <iostream>
#include <bitset> #include <bitset>
#include "PPU.hpp" #include "PPU.hpp"
#include "../Exceptions/NotImplementedException.hpp" #include "Exceptions/NotImplementedException.hpp"
#include "../Exceptions/InvalidAddress.hpp" #include "Exceptions/InvalidAddress.hpp"
#include "../Ram/Ram.hpp" #include "Ram/Ram.hpp"
#include "../Models/Vector2.hpp" #include "Models/Vector2.hpp"
#include <random> #include <random>
namespace ComSquare::PPU namespace ComSquare::PPU
@@ -31,6 +31,8 @@ namespace ComSquare::PPU
_mainScreen({{{0}}}), _mainScreen({{{0}}}),
_subScreen({{{0}}}) _subScreen({{{0}}})
{ {
this->tileRenderer.setRam(this->vram);
this->tileRenderer.setCgram(this->cgram);
this->_registers._isLowByte = true; this->_registers._isLowByte = true;
//colors for the cgram //colors for the cgram
@@ -465,7 +467,10 @@ namespace ComSquare::PPU
void PPU::update(unsigned cycles) void PPU::update(unsigned cycles)
{ {
(void)cycles; (void)cycles;
this->tileRenderer.render();
this->add_buffer(this->_screen, this->tileRenderer.buffer);
/*
this->renderMainAndSubScreen(); this->renderMainAndSubScreen();
this->add_buffer(this->_screen, this->_subScreen); this->add_buffer(this->_screen, this->_subScreen);
this->add_buffer(this->_screen, this->_mainScreen); 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++) { for (unsigned long j = 0; j < this->_screen[i].size(); j++) {
this->_renderer.putPixel(j, i, this->_screen[i][j]); this->_renderer.putPixel(j, i, this->_screen[i][j]);
} }
} }*/
this->_renderer.drawScreen(); this->_renderer.drawScreen();
} }

View File

@@ -6,13 +6,14 @@
#define COMSQUARE_PPU_HPP #define COMSQUARE_PPU_HPP
#include <cstdint> #include <cstdint>
#include "../Memory/AMemory.hpp" #include "Memory/AMemory.hpp"
#include "../Memory/MemoryBus.hpp" #include "Memory/MemoryBus.hpp"
#include "../Renderer/IRenderer.hpp" #include "Renderer/IRenderer.hpp"
#include "../Ram/Ram.hpp" #include "Ram/Ram.hpp"
#include "../Models/Vector2.hpp" #include "Models/Vector2.hpp"
#include "Background.hpp" #include "Background.hpp"
#include "PPUUtils.hpp" #include "PPUUtils.hpp"
#include "Debugger/TileViewer/TileViewer.hpp"
#define FALLTHROUGH __attribute__((fallthrough)); #define FALLTHROUGH __attribute__((fallthrough));
@@ -631,6 +632,8 @@ namespace ComSquare::PPU
Vector2<int> getBgScroll(int bgNumber) const; Vector2<int> getBgScroll(int bgNumber) const;
//! @brief Allow to look the value of each write register (used by Register debugger) //! @brief Allow to look the value of each write register (used by Register debugger)
const Registers &getWriteRegisters() const; const Registers &getWriteRegisters() const;
Debugger::TileRenderer tileRenderer;
}; };
//! @brief Transform SNES color code BGR to uint32_t RGB //! @brief Transform SNES color code BGR to uint32_t RGB

View File

@@ -19,7 +19,7 @@
#include "Debugger/HeaderViewer.hpp" #include "Debugger/HeaderViewer.hpp"
#include "Debugger/CGramDebug.hpp" #include "Debugger/CGramDebug.hpp"
#include "Debugger/RegisterViewer.hpp" #include "Debugger/RegisterViewer.hpp"
#include "Debugger/TileViewer.hpp" #include "Debugger/TileViewer/TileViewer.hpp"
#endif #endif
namespace ComSquare namespace ComSquare