From 1f12627c8ff2e2aca4d2bf794576f5859bf78bb4 Mon Sep 17 00:00:00 2001 From: Matthew Budd Date: Mon, 5 Oct 2020 20:52:09 -0400 Subject: [PATCH] Added initial file for Qt name table viewer --- src/CMakeLists.txt | 1 + src/drivers/Qt/ConsoleWindow.cpp | 16 ++++ src/drivers/Qt/ConsoleWindow.h | 2 + src/drivers/Qt/NameTableViewer.cpp | 133 +++++++++++++++++++++++++++++ src/drivers/Qt/NameTableViewer.h | 73 ++++++++++++++++ 5 files changed, 225 insertions(+) create mode 100644 src/drivers/Qt/NameTableViewer.cpp create mode 100644 src/drivers/Qt/NameTableViewer.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fcf5be14..d8083ce5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -442,6 +442,7 @@ set(SRC_DRIVERS_SDL ${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/AboutWindow.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/fceuWrapper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ppuViewer.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/NameTableViewer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/config.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/input.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/nes_shm.cpp diff --git a/src/drivers/Qt/ConsoleWindow.cpp b/src/drivers/Qt/ConsoleWindow.cpp index 490566c4..71e206a9 100644 --- a/src/drivers/Qt/ConsoleWindow.cpp +++ b/src/drivers/Qt/ConsoleWindow.cpp @@ -34,6 +34,7 @@ #include "Qt/AboutWindow.h" #include "Qt/fceuWrapper.h" #include "Qt/ppuViewer.h" +#include "Qt/NameTableViewer.h" #include "Qt/keyscan.h" #include "Qt/nes_shm.h" @@ -510,6 +511,14 @@ void consoleWin_t::createMainMenu(void) debugMenu->addAction(ppuViewAct); + // Debug -> Name Table Viewer + ntViewAct = new QAction(tr("Name Table Viewer..."), this); + //ntViewAct->setShortcut( QKeySequence(tr("Shift+F7"))); + ntViewAct->setStatusTip(tr("Open Name Table Viewer")); + connect(ntViewAct, SIGNAL(triggered()), this, SLOT(openNTViewer(void)) ); + + debugMenu->addAction(ntViewAct); + // Debug -> Trace Logger traceLogAct = new QAction(tr("Trace Logger..."), this); //traceLogAct->setShortcut( QKeySequence(tr("Shift+F7"))); @@ -1037,6 +1046,13 @@ void consoleWin_t::openPPUViewer(void) openPPUViewWindow(this); } +void consoleWin_t::openNTViewer(void) +{ + //printf("Open GUI Name Table Viewer Window\n"); + + openNameTableViewWindow(this); +} + void consoleWin_t::openCodeDataLogger(void) { CodeDataLoggerDialog_t *cdlWin; diff --git a/src/drivers/Qt/ConsoleWindow.h b/src/drivers/Qt/ConsoleWindow.h index 7699b3ed..cf082440 100644 --- a/src/drivers/Qt/ConsoleWindow.h +++ b/src/drivers/Qt/ConsoleWindow.h @@ -94,6 +94,7 @@ class consoleWin_t : public QMainWindow QAction *traceLogAct; QAction *hexEditAct; QAction *ppuViewAct; + QAction *ntViewAct; QAction *openMovAct; QAction *stopMovAct; QAction *recMovAct; @@ -164,6 +165,7 @@ class consoleWin_t : public QMainWindow void fdsEjectDisk(void); void fdsLoadBiosFile(void); void openPPUViewer(void); + void openNTViewer(void); void openCheats(void); void openMovie(void); void stopMovie(void); diff --git a/src/drivers/Qt/NameTableViewer.cpp b/src/drivers/Qt/NameTableViewer.cpp new file mode 100644 index 00000000..6dab16c7 --- /dev/null +++ b/src/drivers/Qt/NameTableViewer.cpp @@ -0,0 +1,133 @@ +// NameTableViewer.cpp +#include +#include + +#include +#include +#include +#include + +#include "../../types.h" +#include "../../fceu.h" +#include "../../cart.h" +#include "../../ppu.h" +#include "../../debug.h" +#include "../../palette.h" + +#include "Qt/NameTableViewer.h" +#include "Qt/main.h" +#include "Qt/dface.h" +#include "Qt/input.h" +#include "Qt/config.h" +#include "Qt/fceuWrapper.h" + +static ppuNameTableViewerDialog_t *nameTableViewWindow = NULL; + +//---------------------------------------------------- +int openNameTableViewWindow( QWidget *parent ) +{ + if ( nameTableViewWindow != NULL ) + { + return -1; + } + + nameTableViewWindow = new ppuNameTableViewerDialog_t(parent); + + nameTableViewWindow->show(); + + return 0; +} +//---------------------------------------------------- +ppuNameTableViewerDialog_t::ppuNameTableViewerDialog_t(QWidget *parent) + : QDialog( parent ) +{ + QVBoxLayout *mainLayout, *vbox; + QHBoxLayout *hbox; + QGridLayout *grid; + char stmp[64]; + + nameTableViewWindow = this; + + setWindowTitle( tr("Name Table Viewer") ); + + mainLayout = new QVBoxLayout(); + + setLayout( mainLayout ); +} +//---------------------------------------------------- +ppuNameTableViewerDialog_t::~ppuNameTableViewerDialog_t(void) +{ + nameTableViewWindow = NULL; + + printf("Name Table Viewer Window Deleted\n"); +} +//---------------------------------------------------- +void ppuNameTableViewerDialog_t::closeEvent(QCloseEvent *event) +{ + printf("Name Table Viewer Close Window Event\n"); + done(0); + deleteLater(); + event->accept(); +} +//---------------------------------------------------- +void ppuNameTableViewerDialog_t::closeWindow(void) +{ + printf("Close Window\n"); + done(0); + deleteLater(); +} +//---------------------------------------------------- +ppuNameTableView_t::ppuNameTableView_t(QWidget *parent) + : QWidget(parent) +{ + this->setFocusPolicy(Qt::StrongFocus); + this->setMouseTracking(true); + setMinimumWidth( 256 ); + setMinimumHeight( 256 ); + viewWidth = 256; + viewHeight = 256; +} +//---------------------------------------------------- +ppuNameTableView_t::~ppuNameTableView_t(void) +{ + +} +//---------------------------------------------------- +void ppuNameTableView_t::resizeEvent(QResizeEvent *event) +{ + viewWidth = event->size().width(); + viewHeight = event->size().height(); +} +//---------------------------------------------------- +void ppuNameTableView_t::mouseMoveEvent(QMouseEvent *event) +{ + //QPoint tile = convPixToTile( event->pos() ); + + //if ( (tile.x() < 16) && (tile.y() < 16) ) + //{ + // char stmp[64]; + // sprintf( stmp, "Tile: $%X%X", tile.y(), tile.x() ); + // tileLabel->setText( tr(stmp) ); + //} +} +//---------------------------------------------------------------------------- +void ppuNameTableView_t::mousePressEvent(QMouseEvent * event) +{ + //QPoint tile = convPixToTile( event->pos() ); + + if ( event->button() == Qt::LeftButton ) + { + } + else if ( event->button() == Qt::RightButton ) + { + } +} +//---------------------------------------------------- +void ppuNameTableView_t::paintEvent(QPaintEvent *event) +{ + QPainter painter(this); + viewWidth = event->rect().width(); + viewHeight = event->rect().height(); + +} +//---------------------------------------------------- diff --git a/src/drivers/Qt/NameTableViewer.h b/src/drivers/Qt/NameTableViewer.h new file mode 100644 index 00000000..c5de8aee --- /dev/null +++ b/src/drivers/Qt/NameTableViewer.h @@ -0,0 +1,73 @@ +// NameTableViewer.h + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct ppuNameTable_t +{ + struct + { + struct + { + QColor color; + } pixel[8][8]; + + int x; + int y; + + } tile[30][32]; + + int w; + int h; +}; + +class ppuNameTableView_t : public QWidget +{ + Q_OBJECT + + public: + ppuNameTableView_t( QWidget *parent = 0); + ~ppuNameTableView_t(void); + + protected: + void paintEvent(QPaintEvent *event); + void resizeEvent(QResizeEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent * event); + + int viewWidth; + int viewHeight; +}; + +class ppuNameTableViewerDialog_t : public QDialog +{ + Q_OBJECT + + public: + ppuNameTableViewerDialog_t(QWidget *parent = 0); + ~ppuNameTableViewerDialog_t(void); + + protected: + void closeEvent(QCloseEvent *bar); + + public slots: + void closeWindow(void); + private slots: +}; + +int openNameTableViewWindow( QWidget *parent ); +