all repos — mgba @ d5b8fdf81cff2e1cc2dc2836926aa9919ce3146e

mGBA Game Boy Advance Emulator

src/platform/qt/GameController.h (view raw)

  1#ifndef QGBA_GAME_CONTROLLER
  2#define QGBA_GAME_CONTROLLER
  3
  4#include <QFile>
  5#include <QImage>
  6#include <QObject>
  7#include <QMutex>
  8#include <QString>
  9
 10extern "C" {
 11#include "gba-thread.h"
 12#ifdef BUILD_SDL
 13#include "sdl-events.h"
 14#endif
 15}
 16
 17struct GBAAudio;
 18struct GBAVideoSoftwareRenderer;
 19
 20class QThread;
 21
 22namespace QGBA {
 23
 24class AudioProcessor;
 25
 26class GameController : public QObject {
 27Q_OBJECT
 28
 29public:
 30	static const bool VIDEO_SYNC = false;
 31	static const bool AUDIO_SYNC = true;
 32
 33	GameController(QObject* parent = nullptr);
 34	~GameController();
 35
 36	const uint32_t* drawContext() const { return m_drawContext; }
 37	GBAThread* thread() { return &m_threadContext; }
 38
 39	bool isPaused();
 40	bool isLoaded() { return m_gameOpen; }
 41
 42	bool audioSync() const { return m_audioSync; }
 43	bool videoSync() const { return m_videoSync; }
 44
 45#ifdef USE_GDB_STUB
 46	ARMDebugger* debugger();
 47	void setDebugger(ARMDebugger*);
 48#endif
 49
 50signals:
 51	void frameAvailable(const uint32_t*);
 52	void gameStarted(GBAThread*);
 53	void gameStopped(GBAThread*);
 54	void gamePaused(GBAThread*);
 55	void gameUnpaused(GBAThread*);
 56	void stateLoaded(GBAThread*);
 57
 58	void postLog(int level, const QString& log);
 59
 60public slots:
 61	void loadGame(const QString& path, bool dirmode = false);
 62	void loadBIOS(const QString& path);
 63	void loadPatch(const QString& path);
 64	void openGame();
 65	void closeGame();
 66	void setPaused(bool paused);
 67	void reset();
 68	void frameAdvance();
 69	void keyPressed(int key);
 70	void keyReleased(int key);
 71	void setAudioBufferSamples(int samples);
 72	void setFPSTarget(float fps);
 73	void loadState(int slot);
 74	void saveState(int slot);
 75	void setVideoSync(bool);
 76	void setAudioSync(bool);
 77	void setFrameskip(int);
 78	void setTurbo(bool, bool forced = true);
 79	void setAVStream(GBAAVStream*);
 80	void clearAVStream();
 81
 82#ifdef BUILD_SDL
 83private slots:
 84	void testSDLEvents();
 85
 86private:
 87	GBASDLEvents m_sdlEvents;
 88	int m_activeButtons;
 89#endif
 90
 91private:
 92	void updateKeys();
 93
 94	uint32_t* m_drawContext;
 95	GBAThread m_threadContext;
 96	GBAVideoSoftwareRenderer* m_renderer;
 97	int m_activeKeys;
 98
 99	bool m_gameOpen;
100	bool m_dirmode;
101
102	QString m_fname;
103	QString m_bios;
104	QString m_patch;
105
106	QThread* m_audioThread;
107	AudioProcessor* m_audioProcessor;
108
109	QMutex m_pauseMutex;
110	bool m_pauseAfterFrame;
111
112	bool m_videoSync;
113	bool m_audioSync;
114	bool m_turbo;
115	bool m_turboForced;
116};
117
118}
119
120#endif