From d36b7fab1a98d478ac2b6ee195206512c863d66c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Sat, 28 Mar 2020 16:33:13 +0100 Subject: [PATCH] cgram debugger getting logs --- sources/Debugger/CGramDebug.cpp | 30 +++++++++++++++++++++++++----- sources/Debugger/CGramDebug.hpp | 1 - ui/cgramView.ui | 3 +++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/sources/Debugger/CGramDebug.cpp b/sources/Debugger/CGramDebug.cpp index a32ea1a..902cb7e 100644 --- a/sources/Debugger/CGramDebug.cpp +++ b/sources/Debugger/CGramDebug.cpp @@ -5,6 +5,7 @@ #include "CGramDebug.hpp" #include "../SNES.hpp" #include +#include #include "../Utility/Utility.hpp" #include "../Exceptions/InvalidAction.hpp" #include "../Exceptions/InvalidAddress.hpp" @@ -23,6 +24,7 @@ namespace ComSquare::Debugger this->_window->setAttribute(Qt::WA_DeleteOnClose); this->_ui.setupUi(this->_window); + this->_ui.cgram_view->setModel(&this->_model); this->_window->show(); } @@ -62,11 +64,29 @@ int CGramModel::columnCount(const QModelIndex &) const QVariant CGramModel::data(const QModelIndex &index, int role) const { - if (role == Qt::TextAlignmentRole) - return Qt::AlignCenter; - if (role == Qt::BackgroundRole) - return 1; - this->_ppu.cgramRead(0); + u_int16_t addressValue; + uint8_t red; + uint8_t green; + uint8_t blue; + //std::cout << "test1" << std::endl; + //if (role == Qt::TextAlignmentRole) + // return Qt::AlignCenter; + //std::cout << "test2" << std::endl; + //if (role == Qt::BackgroundRole) { + // std::cout << "test" << std::endl; + // return 1; + //} + //std::cout << "test3" << std::endl; if (role != Qt::DisplayRole) return QVariant(); + addressValue = this->_ppu.cgramRead(index.column() * 16 + index.row()); + + blue = (addressValue & 0x7D00U) >> 10U; + green = (addressValue & 0x03E0U) >> 5U; + red = (addressValue & 0x001FU); + + red = (red * 255U / 31U) << 24U; + green = (green * 255U / 31U) << 16U; + blue = (blue * 255U / 31U) << 8U; + return QColor(red, green,blue,255); } \ No newline at end of file diff --git a/sources/Debugger/CGramDebug.hpp b/sources/Debugger/CGramDebug.hpp index 3629795..8cdcbff 100644 --- a/sources/Debugger/CGramDebug.hpp +++ b/sources/Debugger/CGramDebug.hpp @@ -83,7 +83,6 @@ public: 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. diff --git a/ui/cgramView.ui b/ui/cgramView.ui index a110630..73c9102 100644 --- a/ui/cgramView.ui +++ b/ui/cgramView.ui @@ -49,6 +49,9 @@ false + + false +