src/platform/qt/IOViewer.h (view raw)
1/* Copyright (c) 2013-2015 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#pragma once
7
8#include <QDialog>
9#include <QList>
10
11#include <memory>
12
13#include "ui_IOViewer.h"
14
15namespace QGBA {
16
17class CoreController;
18
19class IOViewer : public QDialog {
20Q_OBJECT
21
22public:
23 struct RegisterItem {
24 RegisterItem(const QString& description, uint start, int size = 1, bool readonly = false)
25 : start(start)
26 , size(size)
27 , readonly(readonly)
28 , description(description) {}
29 RegisterItem(const QString& description, uint start, int size, QStringList items, bool readonly = false)
30 : start(start)
31 , size(size)
32 , readonly(readonly)
33 , description(description)
34 , items(items) {}
35 uint start;
36 int size;
37 bool readonly;
38 QString description;
39 QStringList items;
40 };
41 typedef QList<RegisterItem> RegisterDescription;
42
43 IOViewer(std::shared_ptr<CoreController> controller, QWidget* parent = nullptr);
44
45 static const QList<RegisterDescription>& registerDescriptions();
46
47signals:
48 void valueChanged();
49
50public slots:
51 void updateRegister();
52 void selectRegister(int address);
53
54private slots:
55 void buttonPressed(QAbstractButton* button);
56 void bitFlipped();
57 void writeback();
58 void selectRegister();
59
60private:
61 static QList<RegisterDescription> s_registers;
62 Ui::IOViewer m_ui;
63
64 int m_register;
65 uint16_t m_value;
66
67 QCheckBox* m_b[16];
68
69 std::shared_ptr<CoreController> m_controller;
70};
71
72}