mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-06-07 03:34:55 +00:00
starting to implement QTSFML and QTSFMLWIndow
This commit is contained in:
+118
-116
@@ -8,7 +8,7 @@ project(ComSquare)
|
||||
add_compile_options(-W -Wall -Wextra -Wshadow)
|
||||
|
||||
# make unit tests
|
||||
add_executable(unit_tests
|
||||
add_executable(unit_tests EXCLUDE_FROM_ALL
|
||||
tests/CPU/testAddressingMode.cpp
|
||||
tests/CPU/testInterupts.cpp
|
||||
tests/testMemoryBus.cpp
|
||||
@@ -125,121 +125,123 @@ set(CMAKE_AUTOUIC ON)
|
||||
|
||||
# make app
|
||||
add_executable(ComSquare
|
||||
sources/main.cpp
|
||||
sources/SNES.cpp
|
||||
sources/SNES.hpp
|
||||
sources/Memory/MemoryBus.cpp
|
||||
sources/Memory/MemoryBus.hpp
|
||||
sources/Memory/AMemory.hpp
|
||||
sources/Memory/AMemory.cpp
|
||||
sources/PPU/PPU.cpp
|
||||
sources/PPU/PPU.hpp
|
||||
sources/CPU/CPU.cpp
|
||||
sources/CPU/CPU.hpp
|
||||
sources/Cartridge/Cartridge.cpp
|
||||
sources/Cartridge/Cartridge.hpp
|
||||
sources/Exceptions/NotImplementedException.hpp
|
||||
sources/APU/APU.hpp
|
||||
sources/APU/APU.cpp
|
||||
sources/Exceptions/InvalidAddress.hpp
|
||||
sources/Exceptions/InvalidRom.hpp
|
||||
sources/Models/Int24.hpp
|
||||
sources/Models/Int24.hpp
|
||||
sources/Ram/Ram.cpp
|
||||
sources/Ram/Ram.hpp
|
||||
sources/Memory/MemoryShadow.cpp
|
||||
sources/Memory/MemoryShadow.hpp
|
||||
sources/Memory/ARectangleMemory.cpp
|
||||
sources/Memory/ARectangleMemory.hpp
|
||||
sources/APU/DSP/DSP.cpp
|
||||
sources/APU/DSP/DSP.hpp
|
||||
sources/Renderer/IRenderer.hpp
|
||||
sources/Renderer/SFRenderer.hpp
|
||||
sources/Renderer/SFRenderer.cpp
|
||||
sources/Exceptions/InvalidAction.hpp
|
||||
sources/Cartridge/InterruptVectors.hpp
|
||||
sources/Memory/RectangleShadow.cpp
|
||||
sources/Memory/RectangleShadow.hpp
|
||||
sources/Exceptions/InvalidOpcode.hpp
|
||||
sources/CPU/Instructions/Interrupts.cpp
|
||||
sources/CPU/Instructions/MathematicalOperations.cpp
|
||||
sources/APU/Instructions/Standbys.cpp
|
||||
sources/APU/Instructions/ProgramStatusWord.cpp
|
||||
sources/APU/Instructions/Bit.cpp
|
||||
sources/CPU/Instructions/MathematicalOperations.cpp
|
||||
sources/CPU/Instructions/MemoryInstructions.cpp
|
||||
sources/CPU/Instructions/InternalInstruction.cpp
|
||||
sources/Ram/ExtendedRam.cpp
|
||||
sources/Ram/ExtendedRam.hpp
|
||||
sources/Debugger/CPU/CPUDebug.cpp
|
||||
sources/Debugger/CPU/CPUDebug.hpp
|
||||
sources/Renderer/QtRenderer/QtSFML.cpp
|
||||
sources/Renderer/QtRenderer/QtSFML.hpp
|
||||
sources/Renderer/QtRenderer/QtWidgetSFML.cpp
|
||||
sources/Renderer/QtRenderer/QtWidgetSFML.hpp
|
||||
ui/cpuView.ui
|
||||
ui/ramView.ui
|
||||
ui/cartridgeView.ui
|
||||
ui/apuView.ui
|
||||
ui/busView.ui
|
||||
resources/appResources.qrc
|
||||
sources/Utility/Utility.hpp
|
||||
sources/Debugger/MemoryViewer.cpp
|
||||
sources/Debugger/MemoryViewer.hpp
|
||||
sources/Utility/Utility.cpp
|
||||
sources/Debugger/HeaderViewer.cpp
|
||||
sources/Debugger/HeaderViewer.hpp
|
||||
sources/CPU/Instructions/BitsInstructions.cpp
|
||||
sources/Debugger/HeaderViewer.cpp
|
||||
sources/Debugger/HeaderViewer.hpp
|
||||
sources/Debugger/APUDebug.hpp
|
||||
sources/Debugger/APUDebug.cpp
|
||||
sources/APU/Instructions/Stack.cpp
|
||||
sources/APU/Instructions/Subroutine.cpp
|
||||
sources/APU/Instructions/ProgramFlow.cpp
|
||||
sources/APU/Operand.cpp
|
||||
sources/APU/Instructions/DecimalCompensation.cpp
|
||||
sources/APU/Instructions/MultiplicationDivision.cpp
|
||||
sources/APU/Instructions/16bitArithmetic.cpp
|
||||
sources/APU/Instructions/16bitDataTransmission.cpp
|
||||
sources/APU/Instructions/8bitShiftRotation.cpp
|
||||
sources/APU/Instructions/8bitIncrementDecrement.cpp
|
||||
sources/APU/Instructions/8bitLogical.cpp
|
||||
sources/APU/Instructions/8bitArithmetic.cpp
|
||||
sources/APU/Instructions/8bitDataTransmission.cpp
|
||||
sources/APU/IPL/IPL.hpp
|
||||
sources/APU/IPL/IPL.cpp
|
||||
sources/CPU/Instructions/TransferRegisters.cpp
|
||||
sources/CPU/AddressingModes.cpp
|
||||
sources/Debugger/MemoryBusDebug.cpp
|
||||
sources/Debugger/MemoryBusDebug.hpp
|
||||
sources/Debugger/ClosableWindow.hpp
|
||||
sources/Models/Components.hpp
|
||||
sources/CPU/Instruction.hpp
|
||||
sources/Exceptions/DebuggableError.hpp
|
||||
sources/Debugger/CPU/Disassembly.cpp
|
||||
sources/Models/Components.hpp
|
||||
sources/Debugger/CGramDebug.cpp
|
||||
sources/Debugger/CGramDebug.hpp
|
||||
sources/Models/Vector2.hpp
|
||||
sources/PPU/Background.cpp
|
||||
sources/PPU/Background.hpp
|
||||
sources/CPU/DMA/DMA.cpp
|
||||
sources/CPU/DMA/DMA.hpp
|
||||
ui/registersView.ui
|
||||
sources/Debugger/RegisterViewer.cpp
|
||||
sources/Debugger/RegisterViewer.hpp
|
||||
sources/Memory/IMemory.hpp
|
||||
sources/APU/DSP/Voice.cpp
|
||||
sources/APU/DSP/Echo.cpp
|
||||
sources/APU/DSP/Gauss.cpp
|
||||
sources/APU/DSP/Envelope.cpp
|
||||
sources/APU/DSP/Timer.cpp
|
||||
sources/APU/DSP/BRR.cpp
|
||||
sources/PPU/PPUUtils.cpp
|
||||
sources/Debugger/TileViewer.cpp
|
||||
sources/Debugger/TileViewer.hpp
|
||||
ui/tileView.ui)
|
||||
sources/main.cpp
|
||||
sources/SNES.cpp
|
||||
sources/SNES.hpp
|
||||
sources/Memory/MemoryBus.cpp
|
||||
sources/Memory/MemoryBus.hpp
|
||||
sources/Memory/AMemory.hpp
|
||||
sources/Memory/AMemory.cpp
|
||||
sources/PPU/PPU.cpp
|
||||
sources/PPU/PPU.hpp
|
||||
sources/CPU/CPU.cpp
|
||||
sources/CPU/CPU.hpp
|
||||
sources/Cartridge/Cartridge.cpp
|
||||
sources/Cartridge/Cartridge.hpp
|
||||
sources/Exceptions/NotImplementedException.hpp
|
||||
sources/APU/APU.hpp
|
||||
sources/APU/APU.cpp
|
||||
sources/Exceptions/InvalidAddress.hpp
|
||||
sources/Exceptions/InvalidRom.hpp
|
||||
sources/Models/Int24.hpp
|
||||
sources/Models/Int24.hpp
|
||||
sources/Ram/Ram.cpp
|
||||
sources/Ram/Ram.hpp
|
||||
sources/Memory/MemoryShadow.cpp
|
||||
sources/Memory/MemoryShadow.hpp
|
||||
sources/Memory/ARectangleMemory.cpp
|
||||
sources/Memory/ARectangleMemory.hpp
|
||||
sources/APU/DSP/DSP.cpp
|
||||
sources/APU/DSP/DSP.hpp
|
||||
sources/Renderer/IRenderer.hpp
|
||||
sources/Renderer/SFRenderer.hpp
|
||||
sources/Renderer/SFRenderer.cpp
|
||||
sources/Exceptions/InvalidAction.hpp
|
||||
sources/Cartridge/InterruptVectors.hpp
|
||||
sources/Memory/RectangleShadow.cpp
|
||||
sources/Memory/RectangleShadow.hpp
|
||||
sources/Exceptions/InvalidOpcode.hpp
|
||||
sources/CPU/Instructions/Interrupts.cpp
|
||||
sources/CPU/Instructions/MathematicalOperations.cpp
|
||||
sources/APU/Instructions/Standbys.cpp
|
||||
sources/APU/Instructions/ProgramStatusWord.cpp
|
||||
sources/APU/Instructions/Bit.cpp
|
||||
sources/CPU/Instructions/MathematicalOperations.cpp
|
||||
sources/CPU/Instructions/MemoryInstructions.cpp
|
||||
sources/CPU/Instructions/InternalInstruction.cpp
|
||||
sources/Ram/ExtendedRam.cpp
|
||||
sources/Ram/ExtendedRam.hpp
|
||||
sources/Debugger/CPU/CPUDebug.cpp
|
||||
sources/Debugger/CPU/CPUDebug.hpp
|
||||
sources/Renderer/QtRenderer/QtSFML.cpp
|
||||
sources/Renderer/QtRenderer/QtSFML.hpp
|
||||
sources/Renderer/QtRenderer/QtWidgetSFML.cpp
|
||||
sources/Renderer/QtRenderer/QtWidgetSFML.hpp
|
||||
ui/cpuView.ui
|
||||
ui/ramView.ui
|
||||
ui/cartridgeView.ui
|
||||
ui/apuView.ui
|
||||
ui/busView.ui
|
||||
resources/appResources.qrc
|
||||
sources/Utility/Utility.hpp
|
||||
sources/Debugger/MemoryViewer.cpp
|
||||
sources/Debugger/MemoryViewer.hpp
|
||||
sources/Utility/Utility.cpp
|
||||
sources/Debugger/HeaderViewer.cpp
|
||||
sources/Debugger/HeaderViewer.hpp
|
||||
sources/CPU/Instructions/BitsInstructions.cpp
|
||||
sources/Debugger/HeaderViewer.cpp
|
||||
sources/Debugger/HeaderViewer.hpp
|
||||
sources/Debugger/APUDebug.hpp
|
||||
sources/Debugger/APUDebug.cpp
|
||||
sources/APU/Instructions/Stack.cpp
|
||||
sources/APU/Instructions/Subroutine.cpp
|
||||
sources/APU/Instructions/ProgramFlow.cpp
|
||||
sources/APU/Operand.cpp
|
||||
sources/APU/Instructions/DecimalCompensation.cpp
|
||||
sources/APU/Instructions/MultiplicationDivision.cpp
|
||||
sources/APU/Instructions/16bitArithmetic.cpp
|
||||
sources/APU/Instructions/16bitDataTransmission.cpp
|
||||
sources/APU/Instructions/8bitShiftRotation.cpp
|
||||
sources/APU/Instructions/8bitIncrementDecrement.cpp
|
||||
sources/APU/Instructions/8bitLogical.cpp
|
||||
sources/APU/Instructions/8bitArithmetic.cpp
|
||||
sources/APU/Instructions/8bitDataTransmission.cpp
|
||||
sources/APU/IPL/IPL.hpp
|
||||
sources/APU/IPL/IPL.cpp
|
||||
sources/CPU/Instructions/TransferRegisters.cpp
|
||||
sources/CPU/AddressingModes.cpp
|
||||
sources/Debugger/MemoryBusDebug.cpp
|
||||
sources/Debugger/MemoryBusDebug.hpp
|
||||
sources/Debugger/ClosableWindow.hpp
|
||||
sources/Models/Components.hpp
|
||||
sources/CPU/Instruction.hpp
|
||||
sources/Exceptions/DebuggableError.hpp
|
||||
sources/Debugger/CPU/Disassembly.cpp
|
||||
sources/Models/Components.hpp
|
||||
sources/Debugger/CGramDebug.cpp
|
||||
sources/Debugger/CGramDebug.hpp
|
||||
sources/Models/Vector2.hpp
|
||||
sources/PPU/Background.cpp
|
||||
sources/PPU/Background.hpp
|
||||
sources/CPU/DMA/DMA.cpp
|
||||
sources/CPU/DMA/DMA.hpp
|
||||
ui/registersView.ui
|
||||
sources/Debugger/RegisterViewer.cpp
|
||||
sources/Debugger/RegisterViewer.hpp
|
||||
sources/Memory/IMemory.hpp
|
||||
sources/APU/DSP/Voice.cpp
|
||||
sources/APU/DSP/Echo.cpp
|
||||
sources/APU/DSP/Gauss.cpp
|
||||
sources/APU/DSP/Envelope.cpp
|
||||
sources/APU/DSP/Timer.cpp
|
||||
sources/APU/DSP/BRR.cpp
|
||||
sources/PPU/PPUUtils.cpp
|
||||
sources/Debugger/TileViewer.cpp
|
||||
sources/Debugger/TileViewer.hpp
|
||||
ui/tileView.ui sources/Renderer/QtRenderer/QtRenderSfml.cpp sources/Renderer/QtRenderer/QtRenderSfml.hpp)
|
||||
|
||||
#include_directories(ComSquare sources)
|
||||
|
||||
target_compile_definitions(ComSquare PUBLIC DEBUGGER_ENABLED)
|
||||
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
// Created by cbihan on 5/7/21.
|
||||
//
|
||||
|
||||
namespace ComSquare::Renderer
|
||||
{
|
||||
class QtFullSFML;
|
||||
}
|
||||
|
||||
#include "../Renderer/QtRenderer/QtSFML.hpp"
|
||||
#include "TileViewer.hpp"
|
||||
#include "../SNES.hpp"
|
||||
#include <QColor>
|
||||
@@ -21,9 +27,9 @@ namespace ComSquare::Debugger
|
||||
this->_window->setContextMenuPolicy(Qt::NoContextMenu);
|
||||
this->_window->setAttribute(Qt::WA_QuitOnClose, false);
|
||||
this->_window->setAttribute(Qt::WA_DeleteOnClose);
|
||||
//this->_sfWidget = std::make_unique<Renderer::QtFullSFML>(snes, this->_ui.tab, QPoint(0, 0), QSize(this->_ui.tab->width(), this->_ui.tab->height()), 30);
|
||||
|
||||
this->_ui.setupUi(this->_window);
|
||||
// QMainWindow::connect(this->_ui.cgram_view, &QTableView::pressed, this, &TileViewer::tileClicked);
|
||||
this->_window->show();
|
||||
QEvent::registerEventType();
|
||||
}
|
||||
@@ -48,11 +54,4 @@ namespace ComSquare::Debugger
|
||||
return this->_ppu.cgramRead(addr);
|
||||
}
|
||||
|
||||
void TileViewer::tileClicked(const QModelIndex &index)
|
||||
{
|
||||
return;
|
||||
if (!index.isValid())
|
||||
return;
|
||||
this->updateInfoTile(index.row(), index.column());
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,20 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace ComSquare::Renderer
|
||||
{
|
||||
class QtSFML;
|
||||
}
|
||||
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#include "../PPU/PPU.hpp"
|
||||
#include "../../ui/ui_tileView.h"
|
||||
#include <QtCore/QSortFilterProxyModel>
|
||||
#include <QEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QTableView>
|
||||
#include "ClosableWindow.hpp"
|
||||
//#include "../Renderer/QtRenderer/QtSFML.hpp"
|
||||
#include "../PPU/PPU.hpp"
|
||||
#include "../../ui/ui_tileView.h"
|
||||
|
||||
/*
|
||||
//! @brief The qt model that bind the logs to the view.
|
||||
@@ -55,6 +61,8 @@ namespace ComSquare::Debugger
|
||||
Ui::TileViewer _ui;
|
||||
//! @brief A reference to the ppu
|
||||
ComSquare::PPU::PPU &_ppu;
|
||||
//! @brief the window
|
||||
//Renderer::QtSFML _sfWidget;
|
||||
public:
|
||||
//! @brief Called when the window is closed. Turn off the debugger.
|
||||
void disableViewer();
|
||||
@@ -72,9 +80,5 @@ namespace ComSquare::Debugger
|
||||
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);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Created by cbihan on 18/05/2021.
|
||||
//
|
||||
|
||||
#include "QtRenderSfml.hpp"
|
||||
#include <iostream>
|
||||
|
||||
namespace ComSquare::Renderer
|
||||
{
|
||||
QtRenderSFML::QtRenderSFML(ComSquare::SNES &snes, QWidget *parent, const QPoint &position, const QSize &size, int frameRate)
|
||||
: QtWidgetSFML(parent, position, size, frameRate),
|
||||
_snes(snes)
|
||||
{
|
||||
}
|
||||
|
||||
void QtRenderSFML::_onUpdate()
|
||||
{
|
||||
try {
|
||||
this->_snes.update();
|
||||
} catch (const DebuggableError &e) {
|
||||
std::cout << "Invalid rom's instruction: " << e.what() << std::endl;
|
||||
this->_snes.enableCPUDebuggingWithError(e);
|
||||
} catch (std::exception &e) {
|
||||
std::cerr << "An error occurred: " << e.what() << std::endl;
|
||||
QApplication::quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// Created by cbihan on 18/05/2021.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtWidgets/QWidget>
|
||||
#include <SFML/Graphics/RenderWindow.hpp>
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#include <QtWidgets/QGridLayout>
|
||||
#include "../IRenderer.hpp"
|
||||
#include "../SFRenderer.hpp"
|
||||
#include "QtWidgetSFML.hpp"
|
||||
#include "QtSFML.hpp"
|
||||
|
||||
namespace ComSquare::Renderer
|
||||
{
|
||||
class QtRenderSFML : public QtWidgetSFML
|
||||
{
|
||||
private:
|
||||
//! @brief The main window that the app reside on.
|
||||
//QMainWindow _window;
|
||||
QWidget _window;
|
||||
//! @brief The SFML widget.
|
||||
std::unique_ptr<QtFullSFML> _sfWidget = nullptr;
|
||||
public:
|
||||
|
||||
void setParentWidget(QWidget &widget);
|
||||
//! @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 Add a pixel to the buffer to the coordinates x, y with the color rgba.
|
||||
//! @param X horizontal index.
|
||||
//! @param Y vertical index.
|
||||
//! @param rgba The color of the pixel.
|
||||
void putPixel(unsigned y, unsigned x, uint32_t rgba) override;
|
||||
//! @brief This function doesn't do anything because QT internally handle drawing to the screen.
|
||||
void drawScreen() override;
|
||||
//! @brief Playing all samples from buffer
|
||||
//! @param samples Buffer containing samples
|
||||
//! @param sampleCount number of samples inside buffer
|
||||
void playAudio(std::span<int16_t> samples, uint64_t sampleCount) override;
|
||||
//! @brief Set a new name to the window, if there is already a name it will be overwrite.
|
||||
//! @param newWindowName new title for the window.
|
||||
void setWindowName(std::string &newWindowName) override;
|
||||
//! @brief Constructor that return a SFML renderer inside a QT window.
|
||||
//! @param height _height of the window.
|
||||
//! @param width _width of the window.
|
||||
QtRenderSFML(SNES &snes, QWidget* parent, const QPoint& position, const QSize& size, int frameRate = 0);
|
||||
QtRenderSFML(const QtRenderSFML &) = delete;
|
||||
QtRenderSFML &operator=(const QtRenderSFML &) = delete;
|
||||
~QtRenderSFML() override = default;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
@@ -17,72 +17,15 @@
|
||||
|
||||
namespace ComSquare::Renderer
|
||||
{
|
||||
QtSFML::QtSFML(unsigned int h, unsigned int w) :
|
||||
_window(), _sfWidget(nullptr)
|
||||
QtSFML::QtSFML(QWidget *parentWidget)
|
||||
: _window(parentWidget), _sfWidget(nullptr)
|
||||
{
|
||||
this->_window.resize(w, h);
|
||||
this->_window.setWindowIcon(QIcon(":/resources/Logo.png"));
|
||||
this->_window->resize(parentWidget->width(), parentWidget->height());
|
||||
}
|
||||
|
||||
void QtSFML::createWindow(SNES &snes, int maxFPS)
|
||||
{
|
||||
this->setWindowName(snes.cartridge->header.gameName);
|
||||
this->_sfWidget = std::make_unique<QtFullSFML>(snes, &_window, QPoint(0, 0), QSize(this->_window.width(), this->_window.height()), maxFPS);
|
||||
this->_window.setCentralWidget(this->_sfWidget.get());
|
||||
|
||||
QMenu *file = this->_window.menuBar()->addMenu("&File");
|
||||
//TODO implement rom opening from this menu.
|
||||
(void)file;
|
||||
|
||||
QMenu *game = this->_window.menuBar()->addMenu("&Game");
|
||||
QAction *reset = new QAction("Reset", &this->_window);
|
||||
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 *registerDebugger = new QAction("Registers Viewer", &this->_window);
|
||||
registerDebugger->setShortcut(Qt::Key_F7);
|
||||
QMainWindow::connect(registerDebugger, &QAction::triggered, this->_sfWidget.get(), &QtFullSFML::enableRegisterViewer);
|
||||
debugger->addAction(registerDebugger);
|
||||
|
||||
QAction *tileDebugger = new QAction("Tile Viewer", &this->_window);
|
||||
tileDebugger->setShortcut(Qt::Key_F8);
|
||||
QMainWindow::connect(tileDebugger, &QAction::triggered, this->_sfWidget.get(), &QtFullSFML::enableTileViewer);
|
||||
debugger->addAction(tileDebugger);
|
||||
|
||||
this->_window.show();
|
||||
}
|
||||
|
||||
void QtSFML::putPixel(unsigned y, unsigned x, uint32_t rgba)
|
||||
@@ -164,4 +107,72 @@ namespace ComSquare::Renderer
|
||||
{
|
||||
this->_snes.enableTileViewerDebugging();
|
||||
}
|
||||
|
||||
QtSFMLWindow::QtSFMLWindow(unsigned int height, unsigned int width)
|
||||
: QtSFML(this->_window)
|
||||
{
|
||||
this->_window.resize(width, height);
|
||||
this->_window.setWindowIcon(QIcon(":/resources/Logo.png"));
|
||||
}
|
||||
|
||||
void QtSFMLWindow::createWindow(SNES &snes, int maxFPS)
|
||||
{
|
||||
QtSFML::createWindow(snes, maxFPS);
|
||||
this->setWindowName(snes.cartridge->header.gameName);
|
||||
this->_window.setCentralWidget(this->_sfWidget.get());
|
||||
|
||||
QMenu *file = this->_window.menuBar()->addMenu("&File");
|
||||
//TODO implement rom opening from this menu.
|
||||
(void)file;
|
||||
|
||||
QMenu *game = this->_window.menuBar()->addMenu("&Game");
|
||||
QAction *reset = new QAction("Reset", &this->_window);
|
||||
QMainWindow::connect(reset, &QAction::triggered, this->window.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 *registerDebugger = new QAction("Registers Viewer", &this->_window);
|
||||
registerDebugger->setShortcut(Qt::Key_F7);
|
||||
QMainWindow::connect(registerDebugger, &QAction::triggered, this->_sfWidget.get(), &QtFullSFML::enableRegisterViewer);
|
||||
debugger->addAction(registerDebugger);
|
||||
|
||||
QAction *tileDebugger = new QAction("Tile Viewer", &this->_window);
|
||||
tileDebugger->setShortcut(Qt::Key_F8);
|
||||
QMainWindow::connect(tileDebugger, &QAction::triggered, this->_sfWidget.get(), &QtFullSFML::enableTileViewer);
|
||||
debugger->addAction(tileDebugger);
|
||||
|
||||
this->_window.show();
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ namespace ComSquare::Renderer
|
||||
void enableCgramViewer();
|
||||
//! @brief Action called when clicking on the enable DMA viewer button.
|
||||
void enableRegisterViewer();
|
||||
//! @brief Action called when clicking on the enable Tile viwer button
|
||||
//! @brief Action called when clicking on the enable Tile viewer button
|
||||
void enableTileViewer();
|
||||
|
||||
//! @brief Action called when clicking on the reset button.
|
||||
@@ -49,17 +49,18 @@ namespace ComSquare::Renderer
|
||||
~QtFullSFML() override = default;
|
||||
};
|
||||
|
||||
//! @brief A SFML renderer inside a QT window.
|
||||
//! @brief A SFML renderer inside a QT widget.
|
||||
class QtSFML : public IRenderer {
|
||||
private:
|
||||
//! @brief The main window that the app reside on.
|
||||
QMainWindow _window;
|
||||
//QMainWindow _window;
|
||||
QWidget *_window;
|
||||
//! @brief The SFML widget.
|
||||
std::unique_ptr<QtFullSFML> _sfWidget = nullptr;
|
||||
public:
|
||||
//! @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;
|
||||
virtual void createWindow(SNES &snes, int maxFPS) 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.
|
||||
@@ -74,14 +75,29 @@ namespace ComSquare::Renderer
|
||||
//! @brief Set a new name to the window, if there is already a name it will be overwrite.
|
||||
//! @param newWindowName new title for the window.
|
||||
void setWindowName(std::string &newWindowName) override;
|
||||
//! @brief Constructor that return a SFML renderer inside a QT window.
|
||||
//! @param height _height of the window.
|
||||
//! @param width _width of the window.
|
||||
QtSFML(unsigned int height, unsigned int width);
|
||||
//! @brief Constructor that return a SFML renderer inside a QT widget.
|
||||
QtSFML(QWidget *parentWidget);
|
||||
QtSFML(const QtSFML &) = delete;
|
||||
QtSFML &operator=(const QtSFML &) = delete;
|
||||
~QtSFML() = default;
|
||||
};
|
||||
|
||||
class QtSFMLWindow : public QtSFML {
|
||||
private:
|
||||
//! @brief The main window that the app reside on.
|
||||
QMainWindow _window;
|
||||
public:
|
||||
//! @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 Constructor that return a SFML renderer inside a QT window.
|
||||
//! @param height _height of the window.
|
||||
//! @param width _width of the window.
|
||||
QtSFMLWindow(unsigned int height, unsigned int width);
|
||||
QtSFMLWindow(const QtSFMLWindow &) = delete;
|
||||
QtSFMLWindow &operator=(const QtSFMLWindow &) = delete;
|
||||
~QtSFMLWindow() = default;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //COMSQUARE_QTSFML_HPP
|
||||
|
||||
+1
-2
@@ -6,7 +6,6 @@
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <getopt.h>
|
||||
#include "SNES.hpp"
|
||||
#include "Renderer/SFRenderer.hpp"
|
||||
#include "Renderer/QtRenderer/QtSFML.hpp"
|
||||
|
||||
using namespace ComSquare;
|
||||
@@ -81,7 +80,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
QApplication app(argc, argv);
|
||||
QApplication::setAttribute(Qt::AA_DisableWindowContextHelpButton);
|
||||
Renderer::QtSFML renderer(1100, 1100);
|
||||
Renderer::QtSFMLWindow renderer(1100, 1100);
|
||||
try {
|
||||
SNES snes(argv[1], renderer);
|
||||
renderer.createWindow(snes, 60);
|
||||
|
||||
+5
-2
@@ -24,9 +24,12 @@
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="tabsClosable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Tab 1</string>
|
||||
<string>my truc</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
@@ -70,7 +73,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>577</width>
|
||||
<height>22</height>
|
||||
<height>27</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
||||
Reference in New Issue
Block a user