mirror of
https://github.com/zoriya/ComSquare.git
synced 2025-12-19 21:55:11 +00:00
starting to implement test ui to try to connect window and sfmlQwidget
This commit is contained in:
@@ -237,7 +237,7 @@ add_executable(ComSquare
|
|||||||
sources/APU/DSP/Timer.cpp
|
sources/APU/DSP/Timer.cpp
|
||||||
sources/APU/DSP/BRR.cpp
|
sources/APU/DSP/BRR.cpp
|
||||||
sources/PPU/PPUUtils.cpp
|
sources/PPU/PPUUtils.cpp
|
||||||
)
|
sources/Debugger/TileViewer.cpp sources/Debugger/TileViewer.hpp)
|
||||||
|
|
||||||
target_compile_definitions(ComSquare PUBLIC DEBUGGER_ENABLED)
|
target_compile_definitions(ComSquare PUBLIC DEBUGGER_ENABLED)
|
||||||
|
|
||||||
|
|||||||
58
sources/Debugger/TileViewer.cpp
Normal file
58
sources/Debugger/TileViewer.cpp
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
//
|
||||||
|
// Created by cbihan on 5/7/21.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "TileViewer.hpp"
|
||||||
|
#include "../SNES.hpp"
|
||||||
|
#include <QColor>
|
||||||
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
#include <QtWidgets/QTableWidget>
|
||||||
|
#include "../Utility/Utility.hpp"
|
||||||
|
|
||||||
|
namespace ComSquare::Debugger
|
||||||
|
{
|
||||||
|
TileViewer::TileViewer(SNES &snes, ComSquare::PPU::PPU &ppu)
|
||||||
|
: _window(new ClosableWindow<TileViewer>(*this, &TileViewer::disableViewer)),
|
||||||
|
_snes(snes),
|
||||||
|
_ui(),
|
||||||
|
_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, &TileViewer::tileClicked);
|
||||||
|
this->_window->show();
|
||||||
|
QEvent::registerEventType();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TileViewer::disableViewer()
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TileViewer::focus()
|
||||||
|
{
|
||||||
|
this->_window->activateWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TileViewer::isDebugger()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t TileViewer::read(uint8_t addr)
|
||||||
|
{
|
||||||
|
return this->_ppu.cgramRead(addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TileViewer::tileClicked(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
if (!index.isValid())
|
||||||
|
return;
|
||||||
|
this->updateInfoTile(index.row(), index.column());
|
||||||
|
}
|
||||||
|
}
|
||||||
80
sources/Debugger/TileViewer.hpp
Normal file
80
sources/Debugger/TileViewer.hpp
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
//
|
||||||
|
// Created by cbihan on 5/7/21.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QtWidgets/QMainWindow>
|
||||||
|
#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
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
private:
|
||||||
|
//! @brief The ppu to log the cgram.
|
||||||
|
ComSquare::PPU::PPU &_ppu;
|
||||||
|
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;
|
||||||
|
//! @brief The number of column the table has.
|
||||||
|
int columnCount(const QModelIndex &parent) const override;
|
||||||
|
//! @brief Return a data representing the table cell.
|
||||||
|
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 TileViewer : public QObject {
|
||||||
|
private:
|
||||||
|
//! @brief The QT window for this debugger.
|
||||||
|
ClosableWindow<TileViewer> *_window;
|
||||||
|
//! @brief A reference to the snes (to disable the debugger).
|
||||||
|
SNES &_snes;
|
||||||
|
//! @brief A widget that contain the whole UI.
|
||||||
|
Ui::CgramView _ui;
|
||||||
|
//! @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 TileViewer(SNES &snes, ComSquare::PPU::PPU &ppu);
|
||||||
|
TileViewer(const TileViewer &) = delete;
|
||||||
|
TileViewer &operator=(const TileViewer &) = delete;
|
||||||
|
~TileViewer() = default;
|
||||||
|
|
||||||
|
//! @brief Read data at the CGRAM address send it to the debugger.
|
||||||
|
//! @param addr The address to read from.
|
||||||
|
//! @return The color value in BGR, looks like this xbbbbbgggggrrrrr.
|
||||||
|
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);
|
||||||
|
};
|
||||||
|
}
|
||||||
82
ui/testSfml.ui
Normal file
82
ui/testSfml.ui
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>TileViwer</class>
|
||||||
|
<widget class="QMainWindow" name="TileViwer">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>577</width>
|
||||||
|
<height>478</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Palette Viewer</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="QTabWidget" name="tabWidget">
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="tab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Tab 1</string>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_2">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Tab 2</string>
|
||||||
|
</attribute>
|
||||||
|
<widget class="QPushButton" name="pushButton">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>250</x>
|
||||||
|
<y>170</y>
|
||||||
|
<width>83</width>
|
||||||
|
<height>25</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>PushButton</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" name="pushButton_2">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>150</x>
|
||||||
|
<y>160</y>
|
||||||
|
<width>83</width>
|
||||||
|
<height>25</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>PushButton</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenuBar" name="menuBar">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>577</width>
|
||||||
|
<height>22</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources>
|
||||||
|
<include location="../resources/appResources.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
Reference in New Issue
Block a user