ComSquare
CGramDebug.hpp
Go to the documentation of this file.
1 //
2 // Created by cbihan on 3/27/20.
3 //
4 
5 #pragma once
6 
7 #include <QtWidgets/QMainWindow>
8 #include "PPU/PPU.hpp"
9 #include "ui/ui_cgramView.h"
10 #include <QtCore/QSortFilterProxyModel>
11 #include <QEvent>
12 #include <QMouseEvent>
13 #include <QTableView>
14 #include "ClosableWindow.hpp"
15 
16 namespace ComSquare::Debugger
17 {
19  class CGramModel : public QAbstractTableModel
20  {
21  Q_OBJECT
22  private:
25  public:
27  const int column = 16;
29  const int rows = 16;
30  int x;
31  int y;
32 
33  explicit CGramModel(ComSquare::PPU::PPU &ppu);
34  CGramModel(const CGramModel &) = delete;
35  const CGramModel &operator=(const CGramModel &) = delete;
36  ~CGramModel() override = default;
37 
39  [[nodiscard]] int rowCount(const QModelIndex &parent) const override;
41  [[nodiscard]] int columnCount(const QModelIndex &parent) const override;
43  [[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
44  };
45 
47  class CGramDebug : public QObject
48  {
49  private:
55  Ui::CgramView _ui;
60  public:
61  explicit CGramDebug(SNES &snes, ComSquare::PPU::PPU &ppu);
62  CGramDebug(const CGramDebug &) = delete;
63  CGramDebug &operator=(const CGramDebug &) = delete;
64  ~CGramDebug() override = default;
65 
69  uint16_t read(uint8_t addr);
71  void focus();
73  void updateInfoTile(int row, int column);
75  void tileClicked(const QModelIndex &index);
76  };
77 }
ComSquare::Debugger::CGramDebug::_window
ClosableWindow * _window
The QT window for this debugger.
Definition: CGramDebug.hpp:51
ComSquare::Debugger::CGramModel::column
const int column
The number of columns.
Definition: CGramDebug.hpp:27
ComSquare::Debugger::CGramDebug::_ppu
ComSquare::PPU::PPU & _ppu
A reference to the ppu.
Definition: CGramDebug.hpp:59
ComSquare::Debugger::CGramDebug::_model
CGramModel _model
The Log visualizer model for QT.
Definition: CGramDebug.hpp:57
ComSquare::Debugger::CGramDebug::tileClicked
void tileClicked(const QModelIndex &index)
Update call updateInfoTile with the correct address.
Definition: CGramDebug.cpp:60
ComSquare::Debugger::CGramModel::rows
const int rows
The number of rows.
Definition: CGramDebug.hpp:29
ComSquare::Debugger::CGramDebug::read
uint16_t read(uint8_t addr)
Read data at the CGRAM address send it to the debugger.
Definition: CGramDebug.cpp:35
ComSquare::Debugger::CGramModel::~CGramModel
~CGramModel() override=default
ComSquare::Debugger::ClosableWindow
Definition: ClosableWindow.hpp:12
ComSquare::Debugger::CGramDebug::~CGramDebug
~CGramDebug() override=default
ComSquare::Debugger::CGramDebug::_snes
SNES & _snes
A reference to the snes (to disable the debugger).
Definition: CGramDebug.hpp:53
ComSquare::Debugger::CGramModel::data
QVariant data(const QModelIndex &index, int role) const override
Return a data representing the table cell.
Definition: CGramDebug.cpp:81
ComSquare::Debugger
Definition: APUDebug.cpp:11
ComSquare::Debugger::CGramDebug::CGramDebug
CGramDebug(SNES &snes, ComSquare::PPU::PPU &ppu)
Definition: CGramDebug.cpp:15
ComSquare::SNES
Container of all the components of the SNES.
Definition: SNES.hpp:32
ComSquare::Debugger::CGramDebug::focus
void focus()
Focus the debugger's window.
Definition: CGramDebug.cpp:30
ComSquare::Debugger::CGramModel::_ppu
ComSquare::PPU::PPU & _ppu
The ppu to log the cgram.
Definition: CGramDebug.hpp:24
ComSquare::Debugger::CGramModel::y
int y
Definition: CGramDebug.hpp:31
ComSquare::Debugger::CGramModel::CGramModel
CGramModel(ComSquare::PPU::PPU &ppu)
Definition: CGramDebug.cpp:67
ComSquare::Debugger::CGramModel::columnCount
int columnCount(const QModelIndex &parent) const override
The number of column the table has.
Definition: CGramDebug.cpp:76
ComSquare::Debugger::CGramDebug::_ui
Ui::CgramView _ui
A widget that contain the whole UI.
Definition: CGramDebug.hpp:55
ComSquare::Debugger::CGramDebug::operator=
CGramDebug & operator=(const CGramDebug &)=delete
ComSquare::Debugger::CGramModel::operator=
const CGramModel & operator=(const CGramModel &)=delete
ClosableWindow.hpp
ComSquare::Debugger::CGramDebug
window that allow the user to view all data going through the memory bus.
Definition: CGramDebug.hpp:47
ComSquare::Debugger::CGramDebug::updateInfoTile
void updateInfoTile(int row, int column)
Update the text fields with corresponding tile info.
Definition: CGramDebug.cpp:40
ComSquare::Debugger::CGramModel::x
int x
Definition: CGramDebug.hpp:30
ComSquare::Debugger::CGramModel
The qt model that bind the logs to the view.
Definition: CGramDebug.hpp:19
ComSquare::Debugger::CGramModel::rowCount
int rowCount(const QModelIndex &parent) const override
The number of row the table has.
Definition: CGramDebug.cpp:71
PPU.hpp
ComSquare::PPU::PPU
The class containing all the registers of the PPU.
Definition: PPU.hpp:46