all repos — mgba @ 3d4faa41e281ff042451032190b3191af2737d5a

mGBA Game Boy Advance Emulator

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 <mgba/core/core.h>
12
13#include <memory>
14
15#include "ui_IOViewer.h"
16
17namespace QGBA {
18
19class CoreController;
20
21class IOViewer : public QDialog {
22Q_OBJECT
23
24public:
25	struct RegisterItem {
26		RegisterItem(const QString& description, uint start, int size = 1, bool readonly = false)
27			: start(start)
28			, size(size)
29			, readonly(readonly)
30			, description(description) {}
31		RegisterItem(const QString& description, uint start, int size, QStringList items, bool readonly = false)
32			: start(start)
33			, size(size)
34			, readonly(readonly)
35			, description(description)
36			, items(items) {}
37		uint start;
38		int size;
39		bool readonly;
40		QString description;
41		QStringList items;
42	};
43	typedef QList<RegisterItem> RegisterDescription;
44
45	IOViewer(std::shared_ptr<CoreController> controller, QWidget* parent = nullptr);
46
47	static const QList<RegisterDescription>& registerDescriptions(mPlatform);
48
49signals:
50	void valueChanged();
51
52public slots:
53	void updateRegister();
54	void selectRegister(int address);
55
56private slots:
57	void buttonPressed(QAbstractButton* button);
58	void bitFlipped();
59	void writeback();
60	void selectRegister();
61
62private:
63	static QHash<mPlatform, QList<RegisterDescription>> s_registers;
64	Ui::IOViewer m_ui;
65	uint32_t m_base;
66	int m_width;
67
68	int m_register;
69	uint16_t m_value;
70
71	QCheckBox* m_b[16];
72
73	std::shared_ptr<CoreController> m_controller;
74};
75
76}