mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-05-27 08:11:55 +00:00
compiling but segfault when opening the tileviewer
This commit is contained in:
@@ -18,16 +18,29 @@ namespace ComSquare::Debugger
|
||||
buffer({{0}})
|
||||
{}
|
||||
|
||||
void prepVector(std::vector<std::vector<uint32_t>> &vector, int nbColumns)
|
||||
{
|
||||
std::vector<uint32_t> pixelLine(static_cast<unsigned int>(nbColumns), 0);
|
||||
vector.reserve(8);
|
||||
for (int i = 0; i < 8; i++) {
|
||||
vector.push_back(pixelLine);
|
||||
}
|
||||
}
|
||||
|
||||
void RAMTileRenderer::render()
|
||||
{
|
||||
int bufX = 0;
|
||||
int bufY = 0;
|
||||
int nbTilesDrawn = 0;
|
||||
int resetX = bufX;
|
||||
int nbLinesDrawn = 0;
|
||||
//for (auto &i : this->buffer)
|
||||
// i.fill(0);
|
||||
uint24_t limit = std::fmin(this->_ram.getSize(), this->_renderSize) + this->_ramOffset;
|
||||
std::vector<std::vector<uint32_t>> row;
|
||||
|
||||
|
||||
prepVector(row, this->_nbColumns);
|
||||
for (uint24_t i = this->_ramOffset; i < limit; i += PPU::Tile::BaseByteSize * this->_bpp, nbTilesDrawn++) {
|
||||
if (bufX > 1024 || bufY > 1024)
|
||||
break;
|
||||
@@ -40,14 +53,19 @@ namespace ComSquare::Debugger
|
||||
}
|
||||
if (nbTilesDrawn && nbTilesDrawn % this->_nbColumns == 0) {
|
||||
nbTilesDrawn = 0;
|
||||
nbLinesDrawn++;
|
||||
resetX = 0;
|
||||
bufX = resetX;
|
||||
bufY += PPU::Tile::NbPixelsHeight;
|
||||
bufX = 0;
|
||||
bufY = 0;
|
||||
this->buffer.insert(this->buffer.end(), row.begin(), row.end());
|
||||
prepVector(row, this->_nbColumns);
|
||||
}
|
||||
|
||||
for (const auto &raw : this->_tileRenderer.buffer) {
|
||||
for (const auto &pixel : raw) {
|
||||
this->buffer[bufX++][bufY] = pixel;
|
||||
row[bufX++][bufY] = pixel;
|
||||
}
|
||||
bufY++;
|
||||
bufX = resetX;
|
||||
|
||||
@@ -23,8 +23,8 @@ namespace ComSquare::Debugger
|
||||
_ramTileRenderer(ppu.vram, ppu.cgram)
|
||||
{
|
||||
this->_ui.setupUi(this->_window);
|
||||
this->_qtSfmlRenderer(this->_ui.widget_sfml, 30);
|
||||
this->_renderer = this->_qtSfmlRenderer;
|
||||
//this->_qtSfmlRenderer(this->_ui.widget_sfml, 30);
|
||||
this->_renderer = std::make_unique<Renderer::QtSFMLTileRenderer>(this->_ui.widget_sfml, 30);;
|
||||
// this->_sfWidget = std::make_unique<Renderer::QtSFMLTileRenderer>(this->_ui.widget_sfml);
|
||||
QMainWindow::connect(this->_ui.NbColumns, QOverload<int>::of(&QSpinBox::valueChanged), this,
|
||||
[this](int nb) -> void { this->setNbColumns(nb); });
|
||||
@@ -116,7 +116,7 @@ namespace ComSquare::Debugger
|
||||
int j = 0;
|
||||
for (const auto &row : this->_ramTileRenderer.buffer) {
|
||||
for (const auto &pixel : row) {
|
||||
this->_renderer.putPixel(j++, i, pixel);
|
||||
this->_renderer->putPixel(j++, i, pixel);
|
||||
}
|
||||
j = 0;
|
||||
i++;
|
||||
|
||||
@@ -34,10 +34,8 @@ namespace ComSquare::Debugger
|
||||
//std::unique_ptr<Renderer::QtSFMLTileRenderer> _sfWidget;
|
||||
//! @brief The ram tile renderer
|
||||
RAMTileRenderer _ramTileRenderer;
|
||||
//! @brief The instantiation of the renderer (should be passed via argument)
|
||||
Renderer::QtWidgetSFML _qtSfmlRenderer;
|
||||
//! @brief Renderer used to display tiles
|
||||
Renderer::IRenderer &_renderer;
|
||||
std::unique_ptr<Renderer::IRenderer> _renderer;
|
||||
//! @brief Change the bpp from the index given by the ui (QT combo box)
|
||||
void _bppChangeUIHandler(int index);
|
||||
|
||||
|
||||
@@ -48,6 +48,11 @@ namespace ComSquare::Renderer
|
||||
this->_window->setWindowTitle((newWindowName + " - ComSquare").c_str());
|
||||
}
|
||||
|
||||
void QtSFML::setSize(unsigned int width, unsigned int height)
|
||||
{
|
||||
this->_sfWidget->setSize(width, height);
|
||||
}
|
||||
|
||||
QtFullSFML::QtFullSFML(SNES &snes, QWidget *parent, const QPoint &position, const QSize &size, int frameRate) :
|
||||
QtWidgetSFML(parent, position, size, frameRate),
|
||||
_snes(snes)
|
||||
|
||||
@@ -65,6 +65,10 @@ namespace ComSquare::Renderer
|
||||
//! @brief Use this function to create the window.
|
||||
//! @param maxFPS The number of FPS you aim to run on.
|
||||
void createWindow(SNES &snes, int maxFPS) override;
|
||||
//! @brief Set a size or resize the Renderer drawing size
|
||||
//! @param height The new height of the renderer in pixels
|
||||
//! @param width The new width of the renderer in pixels
|
||||
void setSize(unsigned width, unsigned height) 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.
|
||||
|
||||
Reference in New Issue
Block a user