mirror of
https://github.com/zoriya/ComSquare.git
synced 2025-12-19 05:35:10 +00:00
Enabling more debuggers
This commit is contained in:
@@ -53,8 +53,6 @@ set(SOURCES
|
||||
sources/CPU/Instructions/MathematicalOperations.cpp
|
||||
sources/CPU/Instructions/MemoryInstructions.cpp
|
||||
sources/CPU/Instructions/InternalInstruction.cpp
|
||||
sources/Ram/ExtendedRam.cpp
|
||||
sources/Ram/ExtendedRam.hpp
|
||||
sources/Utility/Utility.hpp
|
||||
sources/Utility/Utility.cpp
|
||||
sources/CPU/Instructions/BitsInstructions.cpp
|
||||
@@ -133,14 +131,14 @@ add_executable(comsquare
|
||||
# sources/Debugger/APUDebug.cpp
|
||||
# sources/Debugger/MemoryBusDebug.cpp
|
||||
# sources/Debugger/MemoryBusDebug.hpp
|
||||
# sources/Debugger/CGramDebug.cpp
|
||||
# sources/Debugger/CGramDebug.hpp
|
||||
sources/Debugger/CGramDebug.cpp
|
||||
sources/Debugger/CGramDebug.hpp
|
||||
sources/Debugger/RegisterViewer.cpp
|
||||
sources/Debugger/RegisterViewer.hpp
|
||||
# sources/Debugger/TileViewer/TileViewer.cpp
|
||||
# sources/Debugger/TileViewer/TileViewer.hpp
|
||||
# sources/Debugger/TileViewer/RAMTileRenderer.cpp
|
||||
# sources/Debugger/TileViewer/RAMTileRenderer.hpp
|
||||
sources/Debugger/TileViewer/TileViewer.cpp
|
||||
sources/Debugger/TileViewer/TileViewer.hpp
|
||||
sources/Debugger/TileViewer/RAMTileRenderer.cpp
|
||||
sources/Debugger/TileViewer/RAMTileRenderer.hpp
|
||||
ui/tileView.ui
|
||||
ui/registersView.ui
|
||||
ui/cpuView.ui
|
||||
|
||||
@@ -3,26 +3,21 @@
|
||||
//
|
||||
|
||||
#include "CGramDebug.hpp"
|
||||
#include "../SNES.hpp"
|
||||
#include "SNES.hpp"
|
||||
#include <QColor>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <QtWidgets/QTableWidget>
|
||||
#include "../Utility/Utility.hpp"
|
||||
#include "Utility/Utility.hpp"
|
||||
|
||||
namespace ComSquare::Debugger
|
||||
{
|
||||
CGramDebug::CGramDebug(SNES &snes, ComSquare::PPU::PPU &ppu)
|
||||
: _window(new ClosableWindow<CGramDebug>(*this, &CGramDebug::disableViewer)),
|
||||
: _window(new ClosableWindow([&snes] { snes.disableCgramViewer(); })),
|
||||
_snes(snes),
|
||||
_ui(),
|
||||
_model(ppu),
|
||||
_ppu(ppu)
|
||||
{
|
||||
this->_window->setContextMenuPolicy(Qt::NoContextMenu);
|
||||
this->_window->setAttribute(Qt::WA_QuitOnClose, false);
|
||||
this->_window->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
this->_ui.setupUi(this->_window);
|
||||
QMainWindow::connect(this->_ui.cgram_view, &QTableView::pressed, this, &CGramDebug::tileClicked);
|
||||
this->_ui.cgram_view->setModel(&this->_model);
|
||||
@@ -31,21 +26,11 @@ namespace ComSquare::Debugger
|
||||
QEvent::registerEventType();
|
||||
}
|
||||
|
||||
void CGramDebug::disableViewer()
|
||||
{
|
||||
this->_snes.disableCgramDebugging();
|
||||
}
|
||||
|
||||
void CGramDebug::focus()
|
||||
{
|
||||
this->_window->activateWindow();
|
||||
}
|
||||
|
||||
bool CGramDebug::isDebugger()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
uint16_t CGramDebug::read(uint8_t addr)
|
||||
{
|
||||
return this->_ppu.cgramRead(addr);
|
||||
@@ -79,22 +64,23 @@ namespace ComSquare::Debugger
|
||||
return;
|
||||
this->updateInfoTile(index.row(), index.column());
|
||||
}
|
||||
}
|
||||
|
||||
CGramModel::CGramModel(ComSquare::PPU::PPU &ppu) : _ppu(ppu) {}
|
||||
CGramModel::CGramModel(ComSquare::PPU::PPU &ppu)
|
||||
: _ppu(ppu)
|
||||
{}
|
||||
|
||||
int CGramModel::rowCount(const QModelIndex &) const
|
||||
{
|
||||
int CGramModel::rowCount(const QModelIndex &) const
|
||||
{
|
||||
return this->rows;
|
||||
}
|
||||
}
|
||||
|
||||
int CGramModel::columnCount(const QModelIndex &) const
|
||||
{
|
||||
int CGramModel::columnCount(const QModelIndex &) const
|
||||
{
|
||||
return this->column;
|
||||
}
|
||||
}
|
||||
|
||||
QVariant CGramModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
QVariant CGramModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
u_int16_t addressValue;
|
||||
uint8_t red;
|
||||
uint8_t green;
|
||||
@@ -117,4 +103,5 @@ QVariant CGramModel::data(const QModelIndex &index, int role) const
|
||||
green = green * 255U / 31U;
|
||||
blue = blue * 255U / 31U;
|
||||
return QColor(red, green, blue);
|
||||
}
|
||||
}
|
||||
@@ -2,52 +2,53 @@
|
||||
// Created by cbihan on 3/27/20.
|
||||
//
|
||||
|
||||
#ifndef COMSQUARE_CGRAMDEBUG_HPP
|
||||
#define COMSQUARE_CGRAMDEBUG_HPP
|
||||
#pragma once
|
||||
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#include "../PPU/PPU.hpp"
|
||||
#include "../../ui/ui_cgramView.h"
|
||||
#include "PPU/PPU.hpp"
|
||||
#include "ui/ui_cgramView.h"
|
||||
#include <QtCore/QSortFilterProxyModel>
|
||||
#include <QEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QTableView>
|
||||
#include "ClosableWindow.hpp"
|
||||
|
||||
//! @brief The qt model that bind the logs to the view.
|
||||
class CGramModel : public QAbstractTableModel
|
||||
namespace ComSquare::Debugger
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
//! @brief The qt model that bind the logs to the view.
|
||||
class CGramModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
//! @brief The ppu to log the cgram.
|
||||
ComSquare::PPU::PPU &_ppu;
|
||||
public:
|
||||
public:
|
||||
//! @brief The number of columns
|
||||
const int column = 16;
|
||||
//! @brief The number of rows
|
||||
const int rows = 16;
|
||||
int x;
|
||||
int y;
|
||||
|
||||
explicit CGramModel(ComSquare::PPU::PPU &ppu);
|
||||
CGramModel(const CGramModel &) = delete;
|
||||
const CGramModel &operator=(const CGramModel &) = delete;
|
||||
~CGramModel() override = default;
|
||||
|
||||
//! @brief The number of row the table has.
|
||||
int rowCount(const QModelIndex &parent) const override;
|
||||
[[nodiscard]] int rowCount(const QModelIndex &parent) const override;
|
||||
//! @brief The number of column the table has.
|
||||
int columnCount(const QModelIndex &parent) const override;
|
||||
[[nodiscard]] int columnCount(const QModelIndex &parent) const override;
|
||||
//! @brief Return a data representing the table cell.
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
};
|
||||
[[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
|
||||
};
|
||||
|
||||
namespace ComSquare::Debugger
|
||||
{
|
||||
//! @brief window that allow the user to view all data going through the memory bus.
|
||||
class CGramDebug : public QObject {
|
||||
class CGramDebug : public QObject
|
||||
{
|
||||
private:
|
||||
//! @brief The QT window for this debugger.
|
||||
ClosableWindow<CGramDebug> *_window;
|
||||
ClosableWindow *_window;
|
||||
//! @brief A reference to the snes (to disable the debugger).
|
||||
SNES &_snes;
|
||||
//! @brief A widget that contain the whole UI.
|
||||
@@ -56,14 +57,11 @@ namespace ComSquare::Debugger
|
||||
CGramModel _model;
|
||||
//! @brief A reference to the ppu
|
||||
ComSquare::PPU::PPU &_ppu;
|
||||
public:
|
||||
//! @brief Called when the window is closed. Turn off the debugger.
|
||||
void disableViewer();
|
||||
public:
|
||||
explicit CGramDebug(SNES &snes, ComSquare::PPU::PPU &ppu);
|
||||
CGramDebug(const CGramDebug &) = delete;
|
||||
CGramDebug &operator=(const CGramDebug &) = delete;
|
||||
~CGramDebug() = default;
|
||||
~CGramDebug() override = default;
|
||||
|
||||
//! @brief Read data at the CGRAM address send it to the debugger.
|
||||
//! @param addr The address to read from.
|
||||
@@ -71,13 +69,9 @@ namespace ComSquare::Debugger
|
||||
uint16_t read(uint8_t addr);
|
||||
//! @brief Focus the debugger's window.
|
||||
void focus();
|
||||
//! @brief Return true if the Bus is overloaded with debugging features.
|
||||
bool isDebugger();
|
||||
//! @brief Update the text fields with corresponding tile info
|
||||
void updateInfoTile(int row, int column);
|
||||
//! @brief Update call updateInfoTile with the correct address
|
||||
void tileClicked(const QModelIndex &index);
|
||||
};
|
||||
}
|
||||
|
||||
#endif //COMSQUARE_CGRAMDEBUG_HPP
|
||||
|
||||
@@ -2,30 +2,21 @@
|
||||
// Created by cbihan on 24/05/2021.
|
||||
//
|
||||
|
||||
#include <complex>
|
||||
#include <cmath>
|
||||
#include "RAMTileRenderer.hpp"
|
||||
#include "PPU/PPU.hpp"
|
||||
#include "PPU/Tile.hpp"
|
||||
#include <iostream>
|
||||
|
||||
namespace ComSquare::Debugger
|
||||
{
|
||||
RAMTileRenderer::RAMTileRenderer()
|
||||
: _ram(nullptr),
|
||||
RAMTileRenderer::RAMTileRenderer(Ram::Ram &ram, Ram::Ram &cgram)
|
||||
: _ram(ram),
|
||||
_renderSize(0x5000),
|
||||
_nbColumns(16),
|
||||
_ramOffset(0),
|
||||
_bpp(2),
|
||||
_tileRenderer(ram, cgram),
|
||||
buffer({{{0}}})
|
||||
{
|
||||
}
|
||||
|
||||
void RAMTileRenderer::setRam(std::shared_ptr<Ram::Ram> ram)
|
||||
{
|
||||
this->_ram = ram;
|
||||
this->_tileRenderer.setRam(ram);
|
||||
}
|
||||
{}
|
||||
|
||||
void RAMTileRenderer::render()
|
||||
{
|
||||
@@ -35,7 +26,7 @@ namespace ComSquare::Debugger
|
||||
int resetX = bufX;
|
||||
for (auto &i : this->buffer)
|
||||
i.fill(0);
|
||||
uint24_t limit = fmin(this->_ram->getSize(), this->_renderSize) + this->_ramOffset;
|
||||
uint24_t limit = std::fmin(this->_ram.getSize(), this->_renderSize) + this->_ramOffset;
|
||||
|
||||
for (uint24_t i = this->_ramOffset; i < limit; i += PPU::Tile::BaseByteSize * this->_bpp, nbTilesDrawn++) {
|
||||
if (bufX > 1024 || bufY > 1024)
|
||||
@@ -75,11 +66,6 @@ namespace ComSquare::Debugger
|
||||
this->_tileRenderer.setBpp(bpp);
|
||||
}
|
||||
|
||||
void RAMTileRenderer::setCgram(std::shared_ptr<Ram::Ram> ram)
|
||||
{
|
||||
this->_tileRenderer.setCgram(ram);
|
||||
}
|
||||
|
||||
void RAMTileRenderer::setRenderSize(int size)
|
||||
{
|
||||
this->_renderSize = size;
|
||||
|
||||
@@ -10,10 +10,11 @@
|
||||
|
||||
namespace ComSquare::Debugger
|
||||
{
|
||||
class RAMTileRenderer {
|
||||
class RAMTileRenderer
|
||||
{
|
||||
private:
|
||||
//! @brief ram to render
|
||||
std::shared_ptr<Ram::Ram> _ram;
|
||||
Ram::Ram &_ram;
|
||||
//! @brief The size to render in the ram
|
||||
int _renderSize;
|
||||
//! @brief The number of tile columns to display
|
||||
@@ -29,34 +30,31 @@ namespace ComSquare::Debugger
|
||||
std::array<std::array<uint32_t, 1024>, 1024> buffer;
|
||||
//! @brief Set the palette to use for render (index of palette)
|
||||
void setPaletteIndex(int paletteIndex);
|
||||
//! @brief Set the ram to look for color references
|
||||
void setCgram(std::shared_ptr<Ram::Ram> ram);
|
||||
//! @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 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;
|
||||
[[nodiscard]] int getBpp() const;
|
||||
//! @brief Get the index of the current palette used
|
||||
int getPaletteIndex() const;
|
||||
[[nodiscard]] int getPaletteIndex() const;
|
||||
//! @brief Get the numbr of maximum tile columns to render
|
||||
int getNbColumns() const;
|
||||
[[nodiscard]] int getNbColumns() const;
|
||||
//! @brief render the selected ram
|
||||
void render();
|
||||
|
||||
//! @brief ctor
|
||||
RAMTileRenderer();
|
||||
RAMTileRenderer(Ram::Ram &ram, Ram::Ram &cgram);
|
||||
//! @brief copy ctor
|
||||
RAMTileRenderer(const RAMTileRenderer &) = default;
|
||||
//! @brief dtor
|
||||
~RAMTileRenderer() = default;
|
||||
//! @brief assignment operator
|
||||
RAMTileRenderer &operator=(const RAMTileRenderer &) = default;
|
||||
//! @brief A RAMTileRender is not assignable.
|
||||
RAMTileRenderer &operator=(const RAMTileRenderer &) = delete;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
// Created by cbihan on 5/7/21.
|
||||
//
|
||||
|
||||
namespace ComSquare::Renderer
|
||||
{
|
||||
class QtFullSFML;
|
||||
}
|
||||
|
||||
#include "Renderer/QtRenderer/QtSFML.hpp"
|
||||
#include "TileViewer.hpp"
|
||||
@@ -13,33 +9,30 @@ namespace ComSquare::Renderer
|
||||
#include <QColor>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <QtWidgets/QTableWidget>
|
||||
#include "Utility/Utility.hpp"
|
||||
#include "RAMTileRenderer.hpp"
|
||||
#include "PPU/PPU.hpp"
|
||||
|
||||
namespace ComSquare::Debugger
|
||||
{
|
||||
TileViewer::TileViewer(SNES &snes, ComSquare::PPU::PPU &ppu)
|
||||
: _window(new ClosableWindow<TileViewer>(*this, &TileViewer::disableViewer)),
|
||||
: _window(new ClosableWindow([&snes] { snes.disableTileViewer(); })),
|
||||
_snes(snes),
|
||||
_ui(),
|
||||
_ppu(ppu),
|
||||
_ramTileRenderer()
|
||||
_ramTileRenderer(ppu.vram, ppu.cgram)
|
||||
{
|
||||
this->_ramTileRenderer.setRam(ppu.vram);
|
||||
this->_ramTileRenderer.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::QtSFMLTileRenderer>(this->_ui.widget_sfml);
|
||||
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); });
|
||||
QMainWindow::connect(this->_ui.PaletteIndex, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int nb) -> void { this->setPaletteIndex(nb); });
|
||||
QMainWindow::connect(this->_ui.BppFormat, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this](int index) -> void { this->_bppChangeUIHandler(index); });
|
||||
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); });
|
||||
QMainWindow::connect(this->_ui.PaletteIndex, QOverload<int>::of(&QSpinBox::valueChanged), this,
|
||||
[this](int nb) -> void { this->setPaletteIndex(nb); });
|
||||
QMainWindow::connect(this->_ui.BppFormat, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||
[this](int index) -> void { this->_bppChangeUIHandler(index); });
|
||||
|
||||
// used to setup ui restrictions
|
||||
this->setBpp(this->getBpp());
|
||||
@@ -47,21 +40,11 @@ namespace ComSquare::Debugger
|
||||
this->internalUpdate();
|
||||
}
|
||||
|
||||
void TileViewer::disableViewer()
|
||||
{
|
||||
this->_snes.disableTileViewerDebugging();
|
||||
}
|
||||
|
||||
void TileViewer::focus()
|
||||
{
|
||||
this->_window->activateWindow();
|
||||
}
|
||||
|
||||
bool TileViewer::isDebugger()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
uint16_t TileViewer::read(uint8_t addr)
|
||||
{
|
||||
return this->_ppu.cgramRead(addr);
|
||||
@@ -138,9 +121,12 @@ namespace ComSquare::Debugger
|
||||
void TileViewer::_bppChangeUIHandler(int index)
|
||||
{
|
||||
switch (index) {
|
||||
case 0: return this->setBpp(2);
|
||||
case 1: return this->setBpp(4);
|
||||
case 2: return this->setBpp(8);
|
||||
case 0:
|
||||
return this->setBpp(2);
|
||||
case 1:
|
||||
return this->setBpp(4);
|
||||
case 2:
|
||||
return this->setBpp(8);
|
||||
default:
|
||||
throw std::runtime_error("Invalid Index");
|
||||
}
|
||||
|
||||
@@ -4,11 +4,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace ComSquare::PPU
|
||||
{
|
||||
class PPU;
|
||||
}
|
||||
|
||||
#include <QtCore/QSortFilterProxyModel>
|
||||
#include <QEvent>
|
||||
#include <QMouseEvent>
|
||||
@@ -16,7 +11,7 @@ namespace ComSquare::PPU
|
||||
#include "PPU/PPU.hpp"
|
||||
#include "Debugger/ClosableWindow.hpp"
|
||||
#include "Renderer/QtRenderer/QtSfmlTileRenderer.hpp"
|
||||
#include "../../../ui/ui_tileView.h"
|
||||
#include "ui/ui_tileView.h"
|
||||
#include "Ram/Ram.hpp"
|
||||
#include "RAMTileRenderer.hpp"
|
||||
|
||||
@@ -24,10 +19,11 @@ namespace ComSquare::Debugger
|
||||
{
|
||||
|
||||
//! @brief window that allow the user to view all data going through the memory bus.
|
||||
class TileViewer : public QObject {
|
||||
class TileViewer : public QObject
|
||||
{
|
||||
private:
|
||||
//! @brief The QT window for this debugger.
|
||||
ClosableWindow<TileViewer> *_window;
|
||||
ClosableWindow *_window;
|
||||
//! @brief A reference to the snes (to disable the debugger).
|
||||
SNES &_snes;
|
||||
//! @brief A widget that contain the whole UI.
|
||||
@@ -41,8 +37,6 @@ namespace ComSquare::Debugger
|
||||
//! @brief Change the bpp from the index given by the ui (QT combo box)
|
||||
void _bppChangeUIHandler(int index);
|
||||
public:
|
||||
//! @brief Called when the window is closed. Turn off the debugger.
|
||||
void disableViewer();
|
||||
//! @brief ctor
|
||||
explicit TileViewer(SNES &snes, ComSquare::PPU::PPU &ppu);
|
||||
//! @brief copy ctor
|
||||
@@ -58,8 +52,6 @@ namespace ComSquare::Debugger
|
||||
uint16_t read(uint8_t addr);
|
||||
//! @brief Focus the debugger's window.
|
||||
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
|
||||
@@ -71,13 +63,12 @@ namespace ComSquare::Debugger
|
||||
//! @brief Set the ram offset
|
||||
void setRamOffset(int offset);
|
||||
//! @brief Get the current bpp
|
||||
int getBpp() const;
|
||||
[[nodiscard]] int getBpp() const;
|
||||
//! @brief Get the index of the current palette used
|
||||
int getPaletteIndex() const;
|
||||
[[nodiscard]] int getPaletteIndex() const;
|
||||
//! @brief Get the numbr of maximum tile columns to render
|
||||
int getNbColumns() const;
|
||||
[[nodiscard]] int getNbColumns() const;
|
||||
//! @brief Update the tile renderer
|
||||
void internalUpdate();
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
//
|
||||
// Created by anonymus-raccoon on 2/13/20.
|
||||
//
|
||||
|
||||
#include <cstring>
|
||||
#include "ExtendedRam.hpp"
|
||||
#include "../Exceptions/InvalidAddress.hpp"
|
||||
|
||||
namespace ComSquare::Ram
|
||||
{
|
||||
ExtendedRam::ExtendedRam(size_t size)
|
||||
: _size(size)
|
||||
{
|
||||
this->_data = new uint16_t[size];
|
||||
std::memset(this->_data, 0, size * sizeof(uint16_t));
|
||||
}
|
||||
|
||||
ExtendedRam::~ExtendedRam()
|
||||
{
|
||||
delete [] this->_data;
|
||||
}
|
||||
|
||||
uint16_t ExtendedRam::read(uint24_t addr)
|
||||
{
|
||||
if (addr >= this->_size)
|
||||
throw InvalidAddress("ExtendedRam Read", addr);
|
||||
return this->_data[addr];
|
||||
}
|
||||
|
||||
void ExtendedRam::write(uint24_t addr, uint16_t data)
|
||||
{
|
||||
if (addr >= this->_size)
|
||||
throw InvalidAddress("ExtendedRam Write", addr);
|
||||
this->_data[addr] = data;
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
//
|
||||
// Created by anonymus-raccoon on 2/13/20.
|
||||
//
|
||||
|
||||
#ifndef COMSQUARE_EXTENDEDRAM_HPP
|
||||
#define COMSQUARE_EXTENDEDRAM_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include "../Models/Int24.hpp"
|
||||
|
||||
namespace ComSquare::Ram
|
||||
{
|
||||
class ExtendedRam {
|
||||
private:
|
||||
uint16_t *_data;
|
||||
size_t _size;
|
||||
public:
|
||||
explicit ExtendedRam(size_t size);
|
||||
ExtendedRam(const ExtendedRam &) = delete;
|
||||
ExtendedRam &operator=(const ExtendedRam &) = delete;
|
||||
~ExtendedRam();
|
||||
|
||||
uint16_t read(uint24_t addr);
|
||||
void write(uint24_t addr, uint16_t data);
|
||||
};
|
||||
}
|
||||
|
||||
#endif //COMSQUARE_EXTENDEDRAM_HPP
|
||||
@@ -27,6 +27,16 @@ namespace ComSquare::Ram
|
||||
delete[] this->_data;
|
||||
}
|
||||
|
||||
uint8_t &Ram::operator[](uint24_t addr)
|
||||
{
|
||||
return this->_data[addr];
|
||||
}
|
||||
|
||||
const uint8_t &Ram::operator[](uint24_t addr) const
|
||||
{
|
||||
return this->_data[addr];
|
||||
}
|
||||
|
||||
uint8_t Ram::read(uint24_t addr)
|
||||
{
|
||||
// TODO read/write after the size of the rom should noop or behave like a mirror. I don't really know.
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
// Created by anonymus-raccoon on 1/28/20.
|
||||
//
|
||||
|
||||
#ifndef COMSQUARE_RAM_HPP
|
||||
#define COMSQUARE_RAM_HPP
|
||||
#pragma once
|
||||
|
||||
#include "../Memory/ARectangleMemory.hpp"
|
||||
#include "Memory/ARectangleMemory.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace ComSquare::Ram
|
||||
{
|
||||
class Ram : public Memory::ARectangleMemory {
|
||||
class Ram : public Memory::ARectangleMemory
|
||||
{
|
||||
protected:
|
||||
//! @brief The ram. (Can be used for WRam, SRam, VRam etc)
|
||||
uint8_t *_data;
|
||||
@@ -41,19 +41,26 @@ namespace ComSquare::Ram
|
||||
//! @throw This function should thrown an InvalidAddress for address that are not mapped to the component.
|
||||
void write(uint24_t addr, uint8_t data) override;
|
||||
|
||||
//! @brief Retrieve the data at the address given. This can be used instead of read or write.
|
||||
//! @param addr The address of the data to retrieve.
|
||||
//! @return The data at the address given as parameter.
|
||||
uint8_t &operator[](uint24_t addr);
|
||||
//! @brief Retrieve the data at the address given. This can be used instead of read or write.
|
||||
//! @param addr The address of the data to retrieve.
|
||||
//! @return The data at the address given as parameter.
|
||||
const uint8_t &operator[](uint24_t addr) const;
|
||||
|
||||
//! @brief Get the name of this accessor (used for debug purpose)
|
||||
std::string getName() const override;
|
||||
[[nodiscard]] std::string getName() const override;
|
||||
|
||||
//! @brief Get the component of this accessor (used for debug purpose)
|
||||
Component getComponent() const override;
|
||||
[[nodiscard]] Component getComponent() const override;
|
||||
|
||||
//! @brief Get the size of the ram in bytes.
|
||||
uint24_t getSize() const override;
|
||||
[[nodiscard]] uint24_t getSize() const override;
|
||||
|
||||
//! @brief Get the raw data of the RAM
|
||||
uint8_t *getData() const;
|
||||
//! @return A raw pointer to the data.
|
||||
[[nodiscard]] uint8_t *getData() const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //COMSQUARE_RAM_HPP
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace ComSquare::Renderer
|
||||
|
||||
void QtFullSFML::enableCgramViewer()
|
||||
{
|
||||
// this->_snes.enableCgramDebugging();
|
||||
this->_snes.enableCgramViewer();
|
||||
}
|
||||
|
||||
void QtFullSFML::enableRegisterViewer()
|
||||
@@ -110,7 +110,7 @@ namespace ComSquare::Renderer
|
||||
|
||||
void QtFullSFML::enableTileViewer()
|
||||
{
|
||||
// this->_snes.enableTileViewerDebugging();
|
||||
this->_snes.enableTileViewer();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -132,19 +132,19 @@ namespace ComSquare
|
||||
// this->bus = std::make_shared<Memory::MemoryBus>(*this->bus);
|
||||
// this->cpu->setMemoryBus(this->bus);
|
||||
// }
|
||||
//
|
||||
// void SNES::enableCgramDebugging()
|
||||
// {
|
||||
// if (this->_cgramViewer)
|
||||
// this->_cgramViewer->focus();
|
||||
// else
|
||||
// this->_cgramViewer.emplace(*this, *this->ppu);
|
||||
// }
|
||||
//
|
||||
// void SNES::disableCgramDebugging()
|
||||
// {
|
||||
// this->_cgramViewer = std::nullopt;
|
||||
// }
|
||||
|
||||
void SNES::enableCgramViewer()
|
||||
{
|
||||
if (this->_cgramViewer)
|
||||
this->_cgramViewer->focus();
|
||||
else
|
||||
this->_cgramViewer.emplace(*this, this->ppu);
|
||||
}
|
||||
|
||||
void SNES::disableCgramViewer()
|
||||
{
|
||||
this->_cgramViewer = std::nullopt;
|
||||
}
|
||||
|
||||
void SNES::disableRegisterViewer()
|
||||
{
|
||||
@@ -159,18 +159,18 @@ namespace ComSquare
|
||||
this->_registerViewer.emplace(*this);
|
||||
}
|
||||
|
||||
// void SNES::disableTileViewerDebugging()
|
||||
// {
|
||||
// this->_tileViewer = std::nullopt;
|
||||
// }
|
||||
//
|
||||
// void SNES::enableTileViewerDebugging()
|
||||
// {
|
||||
// if (this->_tileViewer)
|
||||
// this->_tileViewer->focus();
|
||||
// else
|
||||
// this->_tileViewer.emplace(*this, *this->ppu);
|
||||
// }
|
||||
void SNES::disableTileViewer()
|
||||
{
|
||||
this->_tileViewer = std::nullopt;
|
||||
}
|
||||
|
||||
void SNES::enableTileViewer()
|
||||
{
|
||||
if (this->_tileViewer)
|
||||
this->_tileViewer->focus();
|
||||
else
|
||||
this->_tileViewer.emplace(*this, this->ppu);
|
||||
}
|
||||
|
||||
#endif
|
||||
}// namespace ComSquare
|
||||
|
||||
@@ -18,9 +18,10 @@
|
||||
//#include <Debugger/CPU/CPUDebug.hpp>
|
||||
#include "Debugger/MemoryViewer.hpp"
|
||||
#include "Debugger/HeaderViewer.hpp"
|
||||
//#include "Debugger/CGramDebug.hpp"
|
||||
//#include "Debugger/MemoryBusDebug.hpp"
|
||||
#include "Debugger/CGramDebug.hpp"
|
||||
#include "Debugger/RegisterViewer.hpp"
|
||||
//#include "Debugger/TileViewer/TileViewer.hpp"
|
||||
#include "Debugger/TileViewer/TileViewer.hpp"
|
||||
#endif
|
||||
|
||||
namespace ComSquare
|
||||
@@ -38,11 +39,11 @@ namespace ComSquare
|
||||
//! @brief The window that allow the user to view the cartridge's header.
|
||||
std::optional<Debugger::HeaderViewer> _headerViewer;
|
||||
//! @brief The window that allow the user to view the CGRAM.
|
||||
// std::optional<Debugger::CGramDebug> _cgramViewer;
|
||||
std::optional<Debugger::CGramDebug> _cgramViewer;
|
||||
//! @brief The window that allow the user to view registers.
|
||||
std::optional<Debugger::RegisterViewer> _registerViewer;
|
||||
//! @brief The window that allow the user to view the CGRAM as tiles.
|
||||
// std::optional<Debugger::TileViewer> _tileViewer;
|
||||
std::optional<Debugger::TileViewer> _tileViewer;
|
||||
#endif
|
||||
public:
|
||||
//! @brief The memory bus that map addresses to components.
|
||||
@@ -107,18 +108,18 @@ namespace ComSquare
|
||||
// void disableMemoryBusDebugging();
|
||||
// //! @brief Enable the Memory Bus's debugging window.
|
||||
// void enableMemoryBusDebugging();
|
||||
// //! @brief Disable the CGRAM's debugging window.
|
||||
// void disableCgramDebugging();
|
||||
// //! @brief Enable the CGRAM's debugging window.
|
||||
// void enableCgramDebugging();
|
||||
//! @brief Disable the CGRAM's debugging window.
|
||||
void disableCgramViewer();
|
||||
//! @brief Enable the CGRAM's debugging window.
|
||||
void enableCgramViewer();
|
||||
//! @brief Disable the Register's debugging window.
|
||||
void disableRegisterViewer();
|
||||
//! @brief Enable the Register's debugging window.
|
||||
void enableRegisterViewer();
|
||||
// //! @brief Disable the TileViewer's debugging window.
|
||||
// void disableTileViewerDebugging();
|
||||
// //! @brief Enable the TileViewer's debugging window.
|
||||
// void enableTileViewerDebugging();
|
||||
//! @brief Disable the TileViewer's debugging window.
|
||||
void disableTileViewer();
|
||||
//! @brief Enable the TileViewer's debugging window.
|
||||
void enableTileViewer();
|
||||
#endif
|
||||
};
|
||||
}// namespace ComSquare
|
||||
@@ -78,7 +78,7 @@ void parseArguments(int argc, char **argv, SNES &snes)
|
||||
// snes.enableMemoryBusDebugging();
|
||||
// break;
|
||||
// case 'g':
|
||||
// snes.enableCgramDebugging();
|
||||
// snes.enableCgramViewer();
|
||||
// break;
|
||||
case 'r':
|
||||
snes.enableRegisterViewer();
|
||||
|
||||
Reference in New Issue
Block a user