Creating the layout of a DMA viewer

This commit is contained in:
Anonymus Raccoon
2020-05-28 14:13:12 +02:00
parent 29540ce9db
commit 5e0f6104fe
11 changed files with 264 additions and 12 deletions

View File

@@ -99,7 +99,11 @@ add_executable(unit_tests
tests/testRectangleMemory.cpp
tests/CPU/Math/testCMP.cpp
sources/PPU/Backgrounds.cpp
sources/PPU/Background.cpp sources/PPU/Background.hpp sources/CPU/DMA/DMA.cpp sources/CPU/DMA/DMA.hpp)
sources/PPU/Background.cpp
sources/PPU/Background.hpp
sources/CPU/DMA/DMA.cpp
sources/CPU/DMA/DMA.hpp
)
# include criterion & coverage
target_link_libraries(unit_tests criterion -lgcov)
@@ -169,7 +173,7 @@ add_executable(ComSquare
sources/Renderer/QtRenderer/QtSFML.hpp
sources/Renderer/QtRenderer/QtWidgetSFML.cpp
sources/Renderer/QtRenderer/QtWidgetSFML.hpp
ui/cpu.ui
ui/cpuView.ui
ui/ramView.ui
ui/cartridgeView.ui
ui/apuView.ui
@@ -215,7 +219,14 @@ add_executable(ComSquare
sources/Debugger/CGramDebug.hpp
sources/Models/Vector2.hpp
sources/PPU/Backgrounds.cpp
sources/PPU/Background.cpp sources/PPU/Background.hpp sources/CPU/DMA/DMA.cpp sources/CPU/DMA/DMA.hpp)
sources/PPU/Background.cpp
sources/PPU/Background.hpp
sources/CPU/DMA/DMA.cpp
sources/CPU/DMA/DMA.hpp
sources/Debugger/CPU/DMA/DMADebug.cpp
sources/Debugger/CPU/DMA/DMADebug.hpp
ui/dmaView.ui
)
target_compile_definitions(ComSquare PUBLIC DEBUGGER_ENABLED)

View File

@@ -9,7 +9,7 @@
#include "../../CPU/CPU.hpp"
#include "../../Renderer/SFRenderer.hpp"
#include "../../SNES.hpp"
#include "../../../ui/ui_cpu.h"
#include "../../../ui/ui_cpuView.h"
#include "../ClosableWindow.hpp"
namespace ComSquare::Debugger

View File

@@ -0,0 +1,32 @@
//
// Created by anonymus-raccoon on 5/28/20.
//
#include "DMADebug.hpp"
#include "../../../SNES.hpp"
namespace ComSquare::Debugger
{
DMADebug::DMADebug(SNES &snes)
: _window(new ClosableWindow<DMADebug>(*this, &DMADebug::disableDebugger)),
_ui(),
_snes(snes)
{
this->_window->setContextMenuPolicy(Qt::NoContextMenu);
this->_window->setAttribute(Qt::WA_QuitOnClose, false);
this->_window->setAttribute(Qt::WA_DeleteOnClose);
this->_ui.setupUi(this->_window);
this->_window->show();
}
void DMADebug::focus()
{
this->_window->activateWindow();
}
void DMADebug::disableDebugger()
{
this->_snes.disableDMADebugging();
}
}

View File

@@ -0,0 +1,43 @@
//
// Created by anonymus-raccoon on 5/28/20.
//
#ifndef COMSQUARE_DMADEBUG_HPP
#define COMSQUARE_DMADEBUG_HPP
#include <QtCore/QObject>
#include "../../ClosableWindow.hpp"
#include "../../../../ui/ui_dmaView.h"
namespace ComSquare
{
class SNES;
namespace Debugger
{
class DMADebug : public QObject {
private:
//! @brief The QT window for this debugger.
ClosableWindow <DMADebug> *_window;
//! @brief A widget that contain the whole UI.
Ui::DMAView _ui;
//! @brief The snes instance to read/write to DMA channels.
SNES &_snes;
public:
//! @brief Called when the window is closed. Turn off the debugger.
void disableDebugger();
explicit DMADebug(SNES &snes);
DMADebug(
const DMADebug &) = delete;
DMADebug &operator=(const DMADebug &) = delete;
~DMADebug() =default;
//! @brief Focus the debugger's window.
void focus();
};
};
}
#endif //COMSQUARE_DMADEBUG_HPP

View File

@@ -41,32 +41,44 @@ namespace ComSquare::Renderer
QMainWindow::connect(reset, &QAction::triggered, this->_sfWidget.get(), &QtFullSFML::reset);
game->addAction(reset);
QMenu *debugger = this->_window.menuBar()->addMenu("&Debugger");
QAction *cpuDebugger = new QAction("CPU's Debugger", &this->_window);
cpuDebugger->setShortcut(Qt::Key_F1);
QMainWindow::connect(cpuDebugger, &QAction::triggered, this->_sfWidget.get(), &QtFullSFML::enableDebugCPU);
debugger->addAction(cpuDebugger);
QAction *ramViewer = new QAction("Memory viewer", &this->_window);
ramViewer->setShortcut(Qt::Key_F2);
QMainWindow::connect(ramViewer, &QAction::triggered, this->_sfWidget.get(), &QtFullSFML::enableRamViewer);
debugger->addAction(ramViewer);
QAction *headerViewer = new QAction("Header viewer", &this->_window);
headerViewer->setShortcut(Qt::Key_F3);
QMainWindow::connect(headerViewer, &QAction::triggered, this->_sfWidget.get(), &QtFullSFML::enableHeaderViewer);
debugger->addAction(headerViewer);
QAction *apuDebugger = new QAction("APU's Debugger", &this->_window);
apuDebugger->setShortcut(Qt::Key_F4);
QMainWindow::connect(apuDebugger, &QAction::triggered, this->_sfWidget.get(), &QtFullSFML::enableDebugAPU);
debugger->addAction(apuDebugger);
QAction *busDebugger = new QAction("Memory bus Viewer", &this->_window);
busDebugger->setShortcut(Qt::Key_F5);
QMainWindow::connect(busDebugger, &QAction::triggered, this->_sfWidget.get(), &QtFullSFML::enableDebugBus);
debugger->addAction(busDebugger);
QAction *cgramDebugger = new QAction("Palette Viewer", &this->_window);
cgramDebugger->setShortcut(Qt::Key_F6);
QMainWindow::connect(cgramDebugger, &QAction::triggered, this->_sfWidget.get(), &QtFullSFML::enableCgramViewer);
debugger->addAction(cgramDebugger);
QAction *dmaDebugger = new QAction("DMA Viewer", &this->_window);
dmaDebugger->setShortcut(Qt::Key_F7);
QMainWindow::connect(dmaDebugger, &QAction::triggered, this->_sfWidget.get(), &QtFullSFML::enableDMAViewer);
debugger->addAction(dmaDebugger);
this->_window.show();
}
@@ -134,4 +146,9 @@ namespace ComSquare::Renderer
{
this->_snes.enableCgramDebugging();
}
void QtFullSFML::enableDMAViewer()
{
this->_snes.enableDMADebugging();
}
}

View File

@@ -35,8 +35,12 @@ namespace ComSquare::Renderer
void enableDebugBus();
//! @brief Action called when clicking on the enable Palette viewer button.
void enableCgramViewer();
//! @brief Action called when clicking on the enable DMA viewer button.
void enableDMAViewer();
//! @brief Action called when clicking on the reset button.
void reset();
QtFullSFML(SNES &snes, QWidget* parent, const QPoint& position, const QSize& size, int frameRate = 0);
QtFullSFML(const QtFullSFML &) = delete;
QtFullSFML &operator=(const QtFullSFML &) = delete;

View File

@@ -153,4 +153,21 @@ namespace ComSquare
this->_cgramViewer = nullptr;
#endif
}
void SNES::disableDMADebugging()
{
#ifdef DEBUGGER_ENABLED
this->_dmaViewer = nullptr;
#endif
}
void SNES::enableDMADebugging()
{
#ifdef DEBUGGER_ENABLED
if (this->_dmaViewer)
this->_dmaViewer->focus();
else
this->_dmaViewer = std::make_unique<Debugger::DMADebug>(*this);
#endif
}
}

View File

@@ -16,6 +16,7 @@
#include "Debugger/MemoryViewer.hpp"
#include "Debugger/HeaderViewer.hpp"
#include "Debugger/CGramDebug.hpp"
#include "Debugger/CPU/DMA/DMADebug.hpp"
#endif
@@ -31,6 +32,8 @@ namespace ComSquare
std::unique_ptr<Debugger::HeaderViewer> _headerViewer;
//! @brief The window that allow the user to view the CGRAM.
std::unique_ptr<Debugger::CGramDebug> _cgramViewer;
//! @brief The window that allow the user to view the DMA's properties.
std::unique_ptr<Debugger::DMADebug> _dmaViewer;
#endif
//! @brief The memory bus that map addresses to components.
std::shared_ptr<Memory::MemoryBus> _bus;
@@ -77,6 +80,10 @@ namespace ComSquare
void disableCgramDebugging();
//! @brief Enable the Cgram's debugging window.
void enableCgramDebugging();
//! @brief Disable the DMA's debugging window.
void disableDMADebugging();
//! @brief Enable the DMA's debugging window.
void enableDMADebugging();
//! @brief Create all the components using a common memory bus for all of them.
SNES(const std::string &ramPath, Renderer::IRenderer &renderer);

125
ui/dmaView.ui Normal file
View File

@@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DMAView</class>
<widget class="QMainWindow" name="DMAView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>795</width>
<height>534</height>
</rect>
</property>
<property name="windowTitle">
<string>DMA's Debugger</string>
</property>
<property name="windowIcon">
<iconset resource="../resources/appResources.qrc">
<normaloff>:/resources/Logo.png</normaloff>:/resources/Logo.png</iconset>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTableWidget" name="tableWidget">
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustIgnored</enum>
</property>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>28</number>
</attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>86</number>
</attribute>
<attribute name="verticalHeaderDefaultSectionSize">
<number>61</number>
</attribute>
<row>
<property name="text">
<string>Channel 1</string>
</property>
</row>
<row>
<property name="text">
<string>Channel 2</string>
</property>
</row>
<row>
<property name="text">
<string>Channel 3</string>
</property>
</row>
<row>
<property name="text">
<string>Channel 4</string>
</property>
</row>
<row>
<property name="text">
<string>Channel 5</string>
</property>
</row>
<row>
<property name="text">
<string>Channel 6</string>
</property>
</row>
<row>
<property name="text">
<string>Channel 7</string>
</property>
</row>
<row>
<property name="text">
<string>Channel 8</string>
</property>
</row>
<column>
<property name="text">
<string>Mode</string>
</property>
</column>
<column>
<property name="text">
<string>Fixed</string>
</property>
</column>
<column>
<property name="text">
<string>Increment</string>
</property>
</column>
<column>
<property name="text">
<string>Direction</string>
</property>
</column>
<column>
<property name="text">
<string>Port</string>
</property>
</column>
<column>
<property name="text">
<string>A Address</string>
</property>
</column>
<column>
<property name="text">
<string>Count</string>
</property>
</column>
<column>
<property name="text">
<string>Enabled</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</widget>
<resources>
<include location="../resources/appResources.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -1,17 +1,13 @@
/********************************************************************************
** Form generated from reading UI file 'cpu.ui'
** Form generated from reading UI file 'cpuView.ui'
**
<<<<<<< HEAD
** Created by: Qt User Interface Compiler version 5.13.2
=======
** Created by: Qt User Interface Compiler version 5.14.2
>>>>>>> 24bcafeea3896022704904815d263f69f22e5096
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_CPU_H
#define UI_CPU_H
#ifndef UI_CPUVIEW_H
#define UI_CPUVIEW_H
#include <QtCore/QVariant>
#include <QtGui/QIcon>
@@ -458,4 +454,4 @@ namespace Ui {
QT_END_NAMESPACE
#endif // UI_CPU_H
#endif // UI_CPUVIEW_H