-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmainwindow.h
145 lines (125 loc) · 3.79 KB
/
mainwindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QPainter>
#include <QImage>
#include <QTimer>
#include <QThread>
#include <QFile>
#include <QAudioFormat>
#include <QAudioSink>
#include <QAudioDevice>
#include <QMediaDevices>
#include "keysetting.h"
QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE
class NESThread : public QThread {
Q_OBJECT
public:
explicit NESThread(QObject *parent = nullptr, void *buff = nullptr, QString pszFileName = "");
~NESThread();
void setMute(bool mute);
int InfoNES_OpenRom(const char *pszFileName);
int InfoNES_ReadRom(void *buf, unsigned int len);
void InfoNES_CloseRom(void);
void InfoNES_Wait(uint32_t us);
void InfoNES_LoadFrame(uint16_t *frame, uint32_t size);
void InfoNES_PadState(uint32_t *pdwPad1, uint32_t *pdwPad2, uint32_t *pdwSystem);
void InfoNES_SoundOutput(int samples, uint8_t *wave1, uint8_t *wave2, uint8_t *wave3,
uint8_t *wave4, uint8_t *wave5);
void InfoNES_SoundClose(void);
int InfoNES_SoundOpen(int samples_per_sync, int sample_rate);
void InfoNES_SoundInit(void);
void InfoNES_MessageBox(char *buf);
uint16_t *workFrame;
uint32_t pdwPad1 = 0;
uint32_t pdwPad2 = 0;
uint32_t pdwSystem = 0;
QImage *qImg;
QString libVersion;
void processQtKeyEvent(Qt::Key key,bool press);
protected:
void run();
private:
QFile *file = nullptr;
QByteArray *fileName = nullptr;
QAudioSink *audio = nullptr;
QAudioFormat *audioFormat = nullptr;
short *audio_buff = nullptr;
QIODevice *audio_dev = nullptr;
bool m_mute = false;
};
class DGENThread : public QThread {
Q_OBJECT
public:
explicit DGENThread(QObject *parent = nullptr, void *buff = nullptr, QString pszFileName = "");
~DGENThread();
void setMute(bool mute);
int DGEN_OpenRom(const char *pszFileName);
int DGEN_ReadRom(void *buf, unsigned int len);
void DGEN_CloseRom(void);
void DGEN_Wait(uint32_t us);
void DGEN_LoadFrame(uint8_t *frame);
void DGEN_PadState(uint32_t *pdwPad1, uint32_t *pdwPad2, uint32_t *pdwSystem);
void DGEN_SoundOutput(int samples, int16_t *wave);
void DGEN_SoundClose(void);
int DGEN_SoundOpen(int samples_per_sync, int sample_rate);
void DGEN_SoundInit(void);
void DGEN_MessageBox(char *buf);
uint16_t *workFrame;
uint32_t pdwPad1 = 0;
uint32_t pdwPad2 = 0;
uint32_t pdwSystem = 0;
QImage *qImg;
QString libVersion;
void processQtKeyEvent(Qt::Key key,bool press);
protected:
void run();
private:
QFile *file = nullptr;
QByteArray *fileName = nullptr;
QAudioSink *audio = nullptr;
QAudioFormat *audioFormat = nullptr;
short *audio_buff = nullptr;
QIODevice *audio_dev = nullptr;
bool m_mute = false;
};
class MainWindow : public QMainWindow {
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
static const QString VERSION;
static const QString GIT_TAG;
protected:
void paintEvent(QPaintEvent *event);
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event);
private slots:
void timer_repaint();
void sample_1_triggered();
void sample_2_triggered();
void sample_3_triggered();
void sample_4_triggered();
void sample_5_triggered();
void open_triggered();
void close_triggered();
void mute_triggered();
void key_setting_triggered();
void about_triggered();
void about_qt_triggered();
private:
Ui::MainWindow *ui;
QImage *qImg;
uchar *buff;
NESThread *nesThread = nullptr;
DGENThread *dgenThread = nullptr;
QTimer *timer;
KeySetting *key_setting = nullptr;
void start_nesThread(QString file_name);
void start_dgenThread(QString file_name);
};
#endif // MAINWINDOW_H