starting to work

This commit is contained in:
Clément Le Bihan
2021-05-27 17:10:43 +02:00
parent 000cc9f61f
commit e666aca28e
6 changed files with 102 additions and 22 deletions
+9 -4
View File
@@ -32,15 +32,15 @@ namespace ComSquare::Debugger
uint8_t colorReference;
uint24_t color;
std::vector<uint16_t> palette = this->getPalette(this->_paletteIndex);
int bufX = this->_offsetX;
int bufY = this->_offsetY;
int bufX = 0;
int bufY = 0;
int nbTilesDrawn = 0;
int resetX = bufX;
int it = 0;
for (auto &i : buffer)
i.fill(0);
for (uint24_t i = 0; i < fmin(this->_ram->getSize(), this->_renderSize); i += 2, it++) {
for (uint24_t i = this->_ramOffset; i + this->_ramOffset < fmin(this->_ram->getSize(), this->_renderSize); i += 2, it++) {
if (bufX > 1024 || bufY > 1024)
break;
if (it && it % 8 == 0) {
@@ -52,7 +52,7 @@ namespace ComSquare::Debugger
}
if (nbTilesDrawn && nbTilesDrawn % this->_nbColumns == 0) {
nbTilesDrawn = 0;
resetX = this->_offsetX;
resetX = 0;
bufX = resetX;
bufY += PPU::Tile::NbPixelsHeight;
}
@@ -153,4 +153,9 @@ namespace ComSquare::Debugger
{
return this->_nbColumns;
}
void TileRenderer::setRamOffset(int offset)
{
this->_ramOffset = offset;
}
}
+4 -4
View File
@@ -23,10 +23,8 @@ namespace ComSquare::Debugger
int _renderSize;
//! @brief The number of tile columns to display
int _nbColumns;
//! @brief render offset in x
int _offsetX = 0;
//! @brief render offset in y
int _offsetY = 0;
//! @brief Bytes to skip from the start of the ram
int _ramOffset;
public:
//! @brief internal buffer
std::array<std::array<uint32_t, 1024>, 1024> buffer;
@@ -42,6 +40,8 @@ namespace ComSquare::Debugger
void setRenderSize(int size);
//! @brief The ram to render
void setRam(std::shared_ptr<Ram::Ram> ram);
//! @brief Set the ram offset
void setRamOffset(int offset);
//! @brief Get the current bpp
int getBpp() const;
//! @brief Get the index of the current palette used
@@ -15,6 +15,7 @@ namespace ComSquare::Renderer
#include <iostream>
#include <QtWidgets/QTableWidget>
#include "Utility/Utility.hpp"
#include "TileRenderer.hpp"
#include "PPU/PPU.hpp"
namespace ComSquare::Debugger
@@ -26,12 +27,17 @@ namespace ComSquare::Debugger
_ppu(ppu),
_tileRenderer()
{
this->_tileRenderer.setRam(ppu.vram);
this->_tileRenderer.setCgram(ppu.cgram);
this->_window->setContextMenuPolicy(Qt::NoContextMenu);
this->_window->setAttribute(Qt::WA_QuitOnClose, false);
this->_window->setAttribute(Qt::WA_DeleteOnClose);
this->_ui.setupUi(this->_window);
//this->_sfWidget = std::make_unique<Renderer::QtSFML>(this->_ui.tab);
QMainWindow::connect(this->_ui.NbColumns, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int nb) -> void { this->setNbColumns(nb); });
QMainWindow::connect(this->_ui.ByteSize, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int nb) -> void { this->setRenderSize(nb); });
QMainWindow::connect(this->_ui.Address, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int nb) -> void { this->setRamOffset(nb); });
this->_window->show();
QEvent::registerEventType();
}
@@ -55,4 +61,52 @@ namespace ComSquare::Debugger
{
return this->_ppu.cgramRead(addr);
}
void TileViewer::setPaletteIndex(int paletteIndex)
{
this->_tileRenderer.setPaletteIndex(paletteIndex);
}
void TileViewer::setBpp(int bpp)
{
this->_tileRenderer.setBpp(bpp);
}
void TileViewer::setNbColumns(int nbColumns)
{
this->_tileRenderer.setNbColumns(nbColumns);
this->internalUpdate();
}
void TileViewer::setRenderSize(int size)
{
this->_tileRenderer.setRenderSize(size);
this->internalUpdate();
}
int TileViewer::getBpp() const
{
return this->_tileRenderer.getBpp();
}
int TileViewer::getPaletteIndex() const
{
return this->_tileRenderer.getPaletteIndex();
}
int TileViewer::getNbColumns() const
{
return this->_tileRenderer.getNbColumns();
}
void TileViewer::internalUpdate()
{
this->_tileRenderer.render();
this->_ppu.add_buffer(this->_tileRenderer.buffer, {200, 200});
}
void TileViewer::setRamOffset(int offset)
{
this->_tileRenderer.setRamOffset(offset);
}
}
+20 -1
View File
@@ -36,7 +36,7 @@ namespace ComSquare::Debugger
ComSquare::PPU::PPU &_ppu;
//! @brief the window
//std::unique_ptr<Renderer::QtSFML> _sfWidget;
//! @brief The tile renderer
TileRenderer _tileRenderer;
public:
//! @brief Called when the window is closed. Turn off the debugger.
@@ -55,5 +55,24 @@ namespace ComSquare::Debugger
void focus();
//! @brief Return true if the Bus is overloaded with debugging features.
bool isDebugger();
//! @brief Set the palette to use for render (index of palette)
void setPaletteIndex(int paletteIndex);
//! @brief Set the bpp to render graphics
void setBpp(int bpp);
//! @brief Set the number of maximum columns
void setNbColumns(int nbColumns);
//! @brief Set the size of ram to render
void setRenderSize(int size);
//! @brief Set the ram offset
void setRamOffset(int offset);
//! @brief Get the current bpp
int getBpp() const;
//! @brief Get the index of the current palette used
int getPaletteIndex() const;
//! @brief Get the numbr of maximum tile columns to render
int getNbColumns() const;
//! @brief Update the tile renderer
void internalUpdate();
};
}