From 8fa40ad5e09ed2e8bd7b2300980c4942e578381e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Sun, 5 Apr 2020 18:29:06 +0200 Subject: [PATCH] the CGRam debugger is fixed display correctly the cgram and cgram value getter supports all 512 entries of the ram --- sources/Debugger/CGramDebug.cpp | 8 +++++++- sources/PPU/PPU.cpp | 2 +- sources/PPU/PPU.hpp | 2 +- sources/Ram/Ram.hpp | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/sources/Debugger/CGramDebug.cpp b/sources/Debugger/CGramDebug.cpp index 7d46c6f..7150d9f 100644 --- a/sources/Debugger/CGramDebug.cpp +++ b/sources/Debugger/CGramDebug.cpp @@ -5,7 +5,9 @@ #include "CGramDebug.hpp" #include "../SNES.hpp" #include +#include #include +#include #include "../Utility/Utility.hpp" namespace ComSquare::Debugger @@ -50,6 +52,7 @@ namespace ComSquare::Debugger void CGramDebug::updateInfoTile(uint8_t addr) { uint16_t cgramValue = this->_ppu.cgramRead(addr); + cgramValue += this->_ppu.cgramRead(addr + 1) << 8; uint8_t blue = (cgramValue & 0x7D00U) >> 10U; uint8_t green = (cgramValue & 0x03E0U) >> 5U; uint8_t red = (cgramValue & 0x001FU); @@ -90,7 +93,10 @@ QVariant CGramModel::data(const QModelIndex &index, int role) const return Qt::AlignCenter; if (role != Qt::BackgroundRole) return QVariant(); - addressValue = this->_ppu.cgramRead(index.column() * 16 + index.row()); + int idDisplayTile = index.row() * 16 + index.column(); + uint16_t cgramAddress = idDisplayTile / 8 * 16 + (idDisplayTile % 8 * 2); + addressValue = this->_ppu.cgramRead(cgramAddress); + addressValue += this->_ppu.cgramRead(cgramAddress + 1) << 8U; blue = (addressValue & 0x7D00U) >> 10U; green = (addressValue & 0x03E0U) >> 5U; diff --git a/sources/PPU/PPU.cpp b/sources/PPU/PPU.cpp index 3e7ea0d..3eacb63 100644 --- a/sources/PPU/PPU.cpp +++ b/sources/PPU/PPU.cpp @@ -396,7 +396,7 @@ namespace ComSquare::PPU return false; } - uint16_t PPU::cgramRead(uint8_t addr) + uint16_t PPU::cgramRead(uint16_t addr) { return this->cgram->read_internal(addr); } diff --git a/sources/PPU/PPU.hpp b/sources/PPU/PPU.hpp index cd54117..97987a1 100644 --- a/sources/PPU/PPU.hpp +++ b/sources/PPU/PPU.hpp @@ -536,7 +536,7 @@ namespace ComSquare::PPU //! @brief Return true if the CPU is overloaded with debugging features. virtual bool isDebugger(); //! @brief Allow others components to read the CGRAM (Debuggers) - uint16_t cgramRead(uint8_t addr); + uint16_t cgramRead(uint16_t addr); //! @brief Render a background on the screen void renderBackground(int bgNumber, std::vector characterSize, int bpp, bool priority); }; diff --git a/sources/Ram/Ram.hpp b/sources/Ram/Ram.hpp index d9297e7..b7ba17e 100644 --- a/sources/Ram/Ram.hpp +++ b/sources/Ram/Ram.hpp @@ -13,7 +13,7 @@ namespace ComSquare::Ram protected: //! @brief The ram. (Can be used for WRam, SRam, VRam etc) uint8_t *_data; - //! @brief The size of the ram (iny bytes). + //! @brief The size of the ram (in bytes). size_t _size; //! @brief An id identifying the type of memory this is (for the debugger) Component _ramType;