Files
Mu/qtBuildSystem/Mu/emuwrapper.h
meepingsnesroms 4d88e893e0 Launcher work
Gonna try and make the launcher as simple as possible, no zip files, the frontend can handle that if it wants.

Going to make the Qt port launch directorys instead of files too since the file dialog only allows selecting files or directorys and some apps have resource files.
2019-05-18 20:01:28 -07:00

78 lines
2.4 KiB
C++

#pragma once
#include <QPixmap>
#include <QVector>
#include <QString>
#include <QByteArray>
#include <thread>
#include <atomic>
#include <stdint.h>
#include "../../src/emulator.h"
class EmuWrapper{
private:
EmuWrapper(const EmuWrapper&) = delete;//non construction copyable
EmuWrapper& operator=(const EmuWrapper&) = delete;//non copyable
bool emuInited;
std::thread emuThread;
std::atomic<bool> emuThreadJoin;
std::atomic<bool> emuRunning;
std::atomic<bool> emuPaused;
std::atomic<bool> emuNewFrameReady;
QString emuRamFilePath;
QString emuSdCardFilePath;
input_t emuInput;
void emuThreadRun();
public:
enum{
BUTTON_UP = 0,
BUTTON_DOWN,
BUTTON_CALENDAR,
BUTTON_ADDRESS,
BUTTON_TODO,
BUTTON_NOTES,
BUTTON_POWER,
BUTTON_TOTAL_COUNT
};
EmuWrapper();
~EmuWrapper();
uint32_t init(const QString& romPath, const QString& bootloaderPath = "", const QString& ramPath = "", const QString& sdCardPath = "", uint32_t features = FEATURE_ACCURATE);
void exit();
void pause();
void resume();
void reset(bool hard);
uint32_t bootFromFileOrDirectory(const QString& mainPath);
uint32_t saveState(const QString& path);
uint32_t loadState(const QString& path);
bool isInited() const{return emuInited;}
bool isRunning() const{return emuRunning;}
bool isPaused() const{return emuPaused;}
void setPenValue(float x, float y, bool touched);
void setKeyValue(uint8_t key, bool pressed);
uint32_t debugInstallApplication(const QString& path);
QVector<QString>& getDebugStrings();
QVector<uint64_t>& getDuplicateCallCount();
QString getCpuRegisterString();
uint16_t screenWidth() const{return palmFramebufferWidth;}
uint16_t screenHeight() const{return palmFramebufferHeight;}
bool newFrameReady() const{return emuNewFrameReady;}
void frameHandled(){emuNewFrameReady = false;}
//calling these while newFrameReady() == false is undefined behavior, the other thread may be writing to them
const QPixmap getFramebuffer(){return QPixmap::fromImage(QImage((uchar*)palmFramebuffer, palmFramebufferWidth, palmFramebufferHeight, palmFramebufferWidth * sizeof(uint16_t), QImage::Format_RGB16));}
const int16_t* getAudioSamples() const{return palmAudio;}
bool getPowerButtonLed() const{return palmMisc.powerButtonLed;}
uint64_t getEmulatorMemory(uint32_t address, uint8_t size);
};