代码拉取完成,页面将自动刷新
#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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。