added palette viewer debugger to the drop down menu of debuggers

This commit is contained in:
Clément Le Bihan
2020-03-28 19:22:46 +01:00
parent 1b0d243c0e
commit be44a54d30
5 changed files with 33 additions and 6 deletions
+18 -3
View File
@@ -7,9 +7,8 @@
#include <QColor>
#include <iostream>
#include <bitset>
#include <string>
#include "../Utility/Utility.hpp"
#include "../Exceptions/InvalidAction.hpp"
#include "../Exceptions/InvalidAddress.hpp"
namespace ComSquare::Debugger
{
@@ -26,7 +25,7 @@ namespace ComSquare::Debugger
this->_ui.setupUi(this->_window);
this->_ui.cgram_view->setModel(&this->_model);
updateInfoTile(0);
this->_window->show();
}
@@ -49,6 +48,22 @@ namespace ComSquare::Debugger
{
return this->_ppu.cgramRead(addr);
}
void CGramDebug::updateInfoTile(uint8_t addr)
{
uint16_t cgramValue = this->_ppu.cgramRead(addr);
std::cout << "val " << cgramValue << std::endl;
uint8_t blue = (cgramValue & 0x7D00U) >> 10U;
uint8_t green = (cgramValue & 0x03E0U) >> 5U;
uint8_t red = (cgramValue & 0x001FU);
this->_ui.indexLineEdit->setText(std::to_string(addr).c_str());
this->_ui.valueLineEdit->setText(std::to_string(cgramValue).c_str());
this->_ui.rLineEdit->setText(std::to_string(red).c_str());
this->_ui.gLineEdit->setText(std::to_string(green).c_str());
this->_ui.bLineEdit->setText(std::to_string(blue).c_str());
this->_ui.hexLineEdit->setText(Utility::to_hex(cgramValue).c_str());
}
}
CGramModel::CGramModel(ComSquare::PPU::PPU &ppu) : _ppu(ppu) {}
+2 -2
View File
@@ -111,12 +111,12 @@ namespace ComSquare::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(uint8_t addr);
};
}
+9
View File
@@ -59,6 +59,10 @@ namespace ComSquare::Renderer
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);
this->_window.show();
}
@@ -119,4 +123,9 @@ namespace ComSquare::Renderer
{
this->_snes.enableMemoryBusDebugging();
}
void QtFullSFML::enableCgramViewer()
{
this->_snes.enableCgramDebugging();
}
}
+2
View File
@@ -33,6 +33,8 @@ namespace ComSquare::Renderer
void enableDebugAPU();
//! @brief Action called when clicking on the enable Memory Bus debugger button.
void enableDebugBus();
//! @brief Action called when clicking on the enable Palette viewer button.
void enableCgramViewer();
//! @brief Action called when clicking on the reset button.
void reset();
QtFullSFML(SNES &snes, QWidget* parent, const QPoint& position, const QSize& size, int frameRate = 0);
+2 -1
View File
@@ -19,7 +19,8 @@ void usage(char *bin)
<< "\t-c, --cpu: \tEnable the debugger of the CPU." << std::endl
<< "\t-m, --memory: \tEnable the memory viewer panel." << std::endl
<< "\t-h, --header: \tShow the header of the cartridge." << std::endl
<< "\t-b, --bus: \tShow the memory bus's log." << std::endl;
<< "\t-b, --bus: \tShow the memory bus's log." << std::endl
<< "\t-g, --cgram: \tShow the palette viewer." << std::endl;
}
void parseArguments(int argc, char **argv, SNES &snes)