From 64ceb7695cefde89db5a3070b3dcbf25bdc8aa71 Mon Sep 17 00:00:00 2001 From: meepingsnesroms Date: Thu, 26 Jul 2018 16:18:10 -0700 Subject: [PATCH] Add buffer graph viewer and fix some style nits The analog resistance values per pixel can now be seen. The raw RGB16 display mode does have an issue when transitioning from red to green and green to blue where the pixel is almost black though. --- .gitignore | 1 + qtBuildSystem/Mu/Mu.pro.user | 4 +- qtBuildSystem/Mu/debugviewer.h | 12 +- qtBuildSystem/Mu/emuwrapper.h | 3 +- qtBuildSystem/Mu/main.cpp | 4 +- qtBuildSystem/Mu/mainwindow.cpp | 4 +- qtBuildSystem/Mu/mainwindow.h | 7 +- qtBuildSystem/Mu/touchscreen.h | 5 +- tools/BufferGraphViewer/BufferGraphViewer.pro | 38 ++ .../BufferGraphViewer.pro.user | 339 ++++++++++++++++++ tools/BufferGraphViewer/main.cpp | 12 + tools/BufferGraphViewer/mainwindow.cpp | 75 ++++ tools/BufferGraphViewer/mainwindow.h | 36 ++ tools/BufferGraphViewer/mainwindow.ui | 119 ++++++ 14 files changed, 639 insertions(+), 20 deletions(-) create mode 100644 tools/BufferGraphViewer/BufferGraphViewer.pro create mode 100644 tools/BufferGraphViewer/BufferGraphViewer.pro.user create mode 100644 tools/BufferGraphViewer/main.cpp create mode 100644 tools/BufferGraphViewer/mainwindow.cpp create mode 100644 tools/BufferGraphViewer/mainwindow.h create mode 100644 tools/BufferGraphViewer/mainwindow.ui diff --git a/.gitignore b/.gitignore index f3b214c..accecdb 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ /libretroBuildSystem/libs /qtBuildSystem/build-Mu-* /localTester/build-LocalTester-* +/tools/build-BufferGraphViewer-* /localTester/3dsIrForwarder/build /localTester/3dsIrForwarder/3dsIrForwarder.elf /localTester/3dsIrForwarder/3dsIrForwarder.3dsx diff --git a/qtBuildSystem/Mu/Mu.pro.user b/qtBuildSystem/Mu/Mu.pro.user index 75c3a20..b7d831a 100644 --- a/qtBuildSystem/Mu/Mu.pro.user +++ b/qtBuildSystem/Mu/Mu.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -305,10 +305,10 @@ Mu Qt4ProjectManager.Qt4RunConfiguration:/Users/Hoppy/Desktop/projects/PalmEmuRedo/libretro-palmm515emu/qtBuildSystem/Mu/Mu.pro + false true Mu.pro - false /Users/Hoppy/Desktop/projects/PalmEmuRedo/libretro-palmm515emu/qtBuildSystem/build-Mu-Desktop_Qt_5_11_1_clang_64bit-Debug/Mu.app/Contents/MacOS 3768 diff --git a/qtBuildSystem/Mu/debugviewer.h b/qtBuildSystem/Mu/debugviewer.h index 2365af0..4f972b6 100644 --- a/qtBuildSystem/Mu/debugviewer.h +++ b/qtBuildSystem/Mu/debugviewer.h @@ -5,22 +5,22 @@ #include -namespace Ui { +namespace Ui{ class DebugViewer; } -class DebugViewer : public QDialog -{ +class DebugViewer : public QDialog{ Q_OBJECT public: - explicit DebugViewer(QWidget* parent = 0); + explicit DebugViewer(QWidget* parent = nullptr); ~DebugViewer(); -private slots: +private: int64_t numberFromString(QString str, bool negativeAllowed); QString stringFromNumber(int64_t number, bool hex, uint32_t forcedZeros = 0); +private slots: void debugRadioButtonHandler(); void on_debugGetHexValues_clicked(); @@ -35,6 +35,6 @@ private slots: void on_debugEraseDebugLogs_clicked(); private: - uint8_t bitsPerEntry; + uint8_t bitsPerEntry; Ui::DebugViewer* ui; }; diff --git a/qtBuildSystem/Mu/emuwrapper.h b/qtBuildSystem/Mu/emuwrapper.h index 54fe971..7cd6a94 100644 --- a/qtBuildSystem/Mu/emuwrapper.h +++ b/qtBuildSystem/Mu/emuwrapper.h @@ -10,8 +10,7 @@ #include "src/emulator.h" -class EmuWrapper -{ +class EmuWrapper{ private: EmuWrapper(const EmuWrapper&) = delete;//non construction copyable EmuWrapper& operator=(const EmuWrapper&) = delete;//non copyable diff --git a/qtBuildSystem/Mu/main.cpp b/qtBuildSystem/Mu/main.cpp index 1da6e7b..d3783d6 100644 --- a/qtBuildSystem/Mu/main.cpp +++ b/qtBuildSystem/Mu/main.cpp @@ -1,7 +1,9 @@ #include "mainwindow.h" + #include -int main(int argc, char *argv[]){ + +int main(int argc, char* argv[]){ QApplication a(argc, argv); MainWindow w; diff --git a/qtBuildSystem/Mu/mainwindow.cpp b/qtBuildSystem/Mu/mainwindow.cpp index a84365d..0784ced 100644 --- a/qtBuildSystem/Mu/mainwindow.cpp +++ b/qtBuildSystem/Mu/mainwindow.cpp @@ -93,12 +93,12 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event){ } void MainWindow::selectHomePath(){ - QString dir = QFileDialog::getOpenFileName(this, "New Home Directory(\"~/Mu\" is default)", QDir::root().path(), 0); + QString dir = QFileDialog::getOpenFileName(this, "New Home Directory(\"~/Mu\" is default)", QDir::root().path(), nullptr); settings.setValue("resourceDirectory", dir); } void MainWindow::on_install_pressed(){ - QString app = QFileDialog::getOpenFileName(this, "Open *.prc/pdb/pqa", QDir::root().path(), 0); + QString app = QFileDialog::getOpenFileName(this, "Open *.prc/pdb/pqa", QDir::root().path(), nullptr); uint32_t error = emu.installApplication(app); if(error != EMU_ERROR_NONE) popupErrorDialog("Could not install app"); diff --git a/qtBuildSystem/Mu/mainwindow.h b/qtBuildSystem/Mu/mainwindow.h index 39d04e9..e952f8a 100644 --- a/qtBuildSystem/Mu/mainwindow.h +++ b/qtBuildSystem/Mu/mainwindow.h @@ -7,19 +7,18 @@ #include "emuwrapper.h" #include "debugviewer.h" -namespace Ui { +namespace Ui{ class MainWindow; } -class MainWindow : public QMainWindow -{ +class MainWindow : public QMainWindow{ Q_OBJECT public: EmuWrapper emu; QSettings settings; - explicit MainWindow(QWidget* parent = 0); + explicit MainWindow(QWidget* parent = nullptr); ~MainWindow(); private slots: diff --git a/qtBuildSystem/Mu/touchscreen.h b/qtBuildSystem/Mu/touchscreen.h index a0894f8..14fc836 100644 --- a/qtBuildSystem/Mu/touchscreen.h +++ b/qtBuildSystem/Mu/touchscreen.h @@ -4,15 +4,14 @@ #include #include -class TouchScreen : public QLabel -{ +class TouchScreen : public QLabel{ Q_OBJECT private: float rangeSwap(float newRange, float oldRange, float value); public: - explicit TouchScreen(QWidget* parent = 0); + explicit TouchScreen(QWidget* parent = nullptr); ~TouchScreen(); protected: diff --git a/tools/BufferGraphViewer/BufferGraphViewer.pro b/tools/BufferGraphViewer/BufferGraphViewer.pro new file mode 100644 index 0000000..2b7f8ff --- /dev/null +++ b/tools/BufferGraphViewer/BufferGraphViewer.pro @@ -0,0 +1,38 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2018-07-25T09:47:34 +# +#------------------------------------------------- + +QT += core gui widgets + +TARGET = BufferGraphViewer +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG += c++11 + +SOURCES += \ + main.cpp \ + mainwindow.cpp + +HEADERS += \ + mainwindow.h + +FORMS += \ + mainwindow.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/tools/BufferGraphViewer/BufferGraphViewer.pro.user b/tools/BufferGraphViewer/BufferGraphViewer.pro.user new file mode 100644 index 0000000..576f5d9 --- /dev/null +++ b/tools/BufferGraphViewer/BufferGraphViewer.pro.user @@ -0,0 +1,339 @@ + + + + + + EnvironmentId + {706f1b9d-912e-4b1b-8e8d-627ab215aa91} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + true + 80 + false + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + true + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.11.1 clang 64bit + Desktop Qt 5.11.1 clang 64bit + qt.qt5.5111.clang_64_kit + 0 + 0 + 0 + + /Users/Hoppy/Desktop/projects/PalmEmuRedo/libretro-palmm515emu/tools/build-BufferGraphViewer-Desktop_Qt_5_11_1_clang_64bit-Debug + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + /Users/Hoppy/Desktop/projects/PalmEmuRedo/libretro-palmm515emu/tools/build-BufferGraphViewer-Desktop_Qt_5_11_1_clang_64bit-Release + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + true + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + + /Users/Hoppy/Desktop/projects/PalmEmuRedo/libretro-palmm515emu/tools/build-BufferGraphViewer-Desktop_Qt_5_11_1_clang_64bit-Profile + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + true + true + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 3 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy Configuration + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + BufferGraphViewer + + Qt4ProjectManager.Qt4RunConfiguration:/Users/Hoppy/Desktop/projects/PalmEmuRedo/libretro-palmm515emu/tools/BufferGraphViewer/BufferGraphViewer.pro + false + true + + BufferGraphViewer.pro + + /Users/Hoppy/Desktop/projects/PalmEmuRedo/libretro-palmm515emu/tools/build-BufferGraphViewer-Desktop_Qt_5_11_1_clang_64bit-Debug/BufferGraphViewer.app/Contents/MacOS + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 18 + + + Version + 18 + + diff --git a/tools/BufferGraphViewer/main.cpp b/tools/BufferGraphViewer/main.cpp new file mode 100644 index 0000000..7372e93 --- /dev/null +++ b/tools/BufferGraphViewer/main.cpp @@ -0,0 +1,12 @@ +#include "mainwindow.h" + +#include + + +int main(int argc, char* argv[]){ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/tools/BufferGraphViewer/mainwindow.cpp b/tools/BufferGraphViewer/mainwindow.cpp new file mode 100644 index 0000000..e723b55 --- /dev/null +++ b/tools/BufferGraphViewer/mainwindow.cpp @@ -0,0 +1,75 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +#include +#include +#include +#include +#include +#include +#include + +#include + + +MainWindow::MainWindow(QWidget* parent) : + QMainWindow(parent), + ui(new Ui::MainWindow){ + ui->setupUi(this); + + imageData = nullptr; +} + +MainWindow::~MainWindow(){ + if(imageData) + delete[] imageData; + delete ui; +} + +void MainWindow::refreshOnscreenData(){ + //I got lucky RGB16(bbbbbggggggrrrrr) actually has the low end as red and the high end as blue, automatic thermal coloration for free + int interlacedSegments = ui->interlacedSegments->value(); + int activeSegment = ui->segment->value(); + int width = ui->width->value(); + int height = fileData.length() / 2 / interlacedSegments / width; + int imageIndex = activeSegment; + uint16_t* oldImage = imageData; + + imageData = new uint16_t[width * height]; + + for(int y = 0; y < height; y++){ + for(int x = 0; x < width; x++){ + //deinterlace the data + imageData[x + y * width] = fileData[imageIndex * 2] << 8 | fileData[imageIndex * 2 + 1]; + imageIndex += interlacedSegments; + } + } + + //swap out image buffer and delete the old one, the image buffer must remain persistant while the corrisponding QPixmap is displayed + ui->framebuffer->setPixmap(QPixmap::fromImage(QImage((uchar*)imageData, width, height, width * sizeof(uint16_t), QImage::Format_RGB16))); + delete[] oldImage; +} + +void MainWindow::on_loadData_clicked(){ + QString dataPath = QFileDialog::getOpenFileName(this, "Open *.bin", QDir::root().path(), nullptr); + QFile dataFile(dataPath); + + if(dataFile.open(QFile::ReadOnly)){ + fileData = dataFile.readAll(); + dataFile.close(); + refreshOnscreenData(); + } +} + +void MainWindow::on_width_valueChanged(int arg1){ + refreshOnscreenData(); +} + +void MainWindow::on_interlacedSegments_valueChanged(int arg1){ + ui->segment->setMaximum(arg1 - 1); + refreshOnscreenData(); +} + +void MainWindow::on_segment_valueChanged(int arg1){ + refreshOnscreenData(); +} diff --git a/tools/BufferGraphViewer/mainwindow.h b/tools/BufferGraphViewer/mainwindow.h new file mode 100644 index 0000000..9c84aa0 --- /dev/null +++ b/tools/BufferGraphViewer/mainwindow.h @@ -0,0 +1,36 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include + +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow{ + Q_OBJECT + +public: + explicit MainWindow(QWidget* parent = nullptr); + ~MainWindow(); + +private: + void refreshOnscreenData(); + +private slots: + void on_loadData_clicked(); + + void on_width_valueChanged(int arg1); + void on_interlacedSegments_valueChanged(int arg1); + void on_segment_valueChanged(int arg1); + +private: + uint16_t* imageData; + QByteArray fileData; + Ui::MainWindow* ui; +}; + +#endif // MAINWINDOW_H diff --git a/tools/BufferGraphViewer/mainwindow.ui b/tools/BufferGraphViewer/mainwindow.ui new file mode 100644 index 0000000..98543e4 --- /dev/null +++ b/tools/BufferGraphViewer/mainwindow.ui @@ -0,0 +1,119 @@ + + + MainWindow + + + + 0 + 0 + 514 + 366 + + + + Buffer Viewer + + + + + + + Load Data + + + + + + + + 0 + 0 + + + + + 0 + 20 + + + + + + + Width: + + + + + + + 1 + + + 10000 + + + 160 + + + + + + + Interlaced Segments: + + + + + + + 1 + + + 4 + + + + + + + Active Segment: + + + + + + + 3 + + + 0 + + + + + + + + + + QFrame::WinPanel + + + QFrame::Raised + + + + + + Qt::AlignCenter + + + + + + + + + +