mirror of https://github.com/mgba-emu/mgba.git
Core: Restore sleep callback
This commit is contained in:
parent
f0ea421fea
commit
484618ca4c
1
CHANGES
1
CHANGES
|
@ -85,6 +85,7 @@ Misc:
|
||||||
- FFmpeg: Return false if a file fails to open
|
- FFmpeg: Return false if a file fails to open
|
||||||
- FFmpeg: Force MP4 files to YUV420P
|
- FFmpeg: Force MP4 files to YUV420P
|
||||||
- Qt: Make "Mute" able to be bound to a key
|
- Qt: Make "Mute" able to be bound to a key
|
||||||
|
- Core: Restore sleep callback
|
||||||
|
|
||||||
0.5.2: (2016-12-31)
|
0.5.2: (2016-12-31)
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
|
|
@ -38,6 +38,7 @@ struct mCoreCallbacks {
|
||||||
void (*videoFrameStarted)(void* context);
|
void (*videoFrameStarted)(void* context);
|
||||||
void (*videoFrameEnded)(void* context);
|
void (*videoFrameEnded)(void* context);
|
||||||
void (*coreCrashed)(void* context);
|
void (*coreCrashed)(void* context);
|
||||||
|
void (*sleep)(void* context);
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_VECTOR(mCoreCallbacksList, struct mCoreCallbacks);
|
DECLARE_VECTOR(mCoreCallbacksList, struct mCoreCallbacks);
|
||||||
|
@ -53,10 +54,6 @@ struct mKeyCallback {
|
||||||
uint16_t (*readKeys)(struct mKeyCallback*);
|
uint16_t (*readKeys)(struct mKeyCallback*);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mStopCallback {
|
|
||||||
void (*stop)(struct mStopCallback*);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct mRotationSource {
|
struct mRotationSource {
|
||||||
void (*sample)(struct mRotationSource*);
|
void (*sample)(struct mRotationSource*);
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@ struct mCoreThread {
|
||||||
ThreadCallback resetCallback;
|
ThreadCallback resetCallback;
|
||||||
ThreadCallback cleanCallback;
|
ThreadCallback cleanCallback;
|
||||||
ThreadCallback frameCallback;
|
ThreadCallback frameCallback;
|
||||||
|
ThreadCallback sleepCallback;
|
||||||
void* userData;
|
void* userData;
|
||||||
void (*run)(struct mCoreThread*);
|
void (*run)(struct mCoreThread*);
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,6 @@ struct GBA {
|
||||||
|
|
||||||
struct mAVStream* stream;
|
struct mAVStream* stream;
|
||||||
struct mKeyCallback* keyCallback;
|
struct mKeyCallback* keyCallback;
|
||||||
struct mStopCallback* stopCallback;
|
|
||||||
struct mCoreCallbacksList coreCallbacks;
|
struct mCoreCallbacksList coreCallbacks;
|
||||||
|
|
||||||
enum GBAIdleLoopOptimization idleOptimization;
|
enum GBAIdleLoopOptimization idleOptimization;
|
||||||
|
|
|
@ -120,6 +120,16 @@ void _crashed(void* context) {
|
||||||
_changeState(thread, THREAD_CRASHED, true);
|
_changeState(thread, THREAD_CRASHED, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _sleep(void* context) {
|
||||||
|
struct mCoreThread* thread = context;
|
||||||
|
if (!thread) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (thread->sleepCallback) {
|
||||||
|
thread->sleepCallback(thread);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static THREAD_ENTRY _mCoreThreadRun(void* context) {
|
static THREAD_ENTRY _mCoreThreadRun(void* context) {
|
||||||
struct mCoreThread* threadContext = context;
|
struct mCoreThread* threadContext = context;
|
||||||
#ifdef USE_PTHREADS
|
#ifdef USE_PTHREADS
|
||||||
|
@ -143,6 +153,7 @@ static THREAD_ENTRY _mCoreThreadRun(void* context) {
|
||||||
.videoFrameStarted = _frameStarted,
|
.videoFrameStarted = _frameStarted,
|
||||||
.videoFrameEnded = _frameEnded,
|
.videoFrameEnded = _frameEnded,
|
||||||
.coreCrashed = _crashed,
|
.coreCrashed = _crashed,
|
||||||
|
.sleep = _sleep,
|
||||||
.context = threadContext
|
.context = threadContext
|
||||||
};
|
};
|
||||||
core->addCoreCallbacks(core, &callbacks);
|
core->addCoreCallbacks(core, &callbacks);
|
||||||
|
|
|
@ -89,8 +89,6 @@ static void GBAInit(void* cpu, struct mCPUComponent* component) {
|
||||||
|
|
||||||
gba->stream = NULL;
|
gba->stream = NULL;
|
||||||
gba->keyCallback = NULL;
|
gba->keyCallback = NULL;
|
||||||
gba->stopCallback = NULL;
|
|
||||||
gba->stopCallback = NULL;
|
|
||||||
mCoreCallbacksListInit(&gba->coreCallbacks, 0);
|
mCoreCallbacksListInit(&gba->coreCallbacks, 0);
|
||||||
|
|
||||||
gba->biosChecksum = GBAChecksum(gba->memory.bios, SIZE_BIOS);
|
gba->biosChecksum = GBAChecksum(gba->memory.bios, SIZE_BIOS);
|
||||||
|
@ -450,11 +448,14 @@ void GBAHalt(struct GBA* gba) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GBAStop(struct GBA* gba) {
|
void GBAStop(struct GBA* gba) {
|
||||||
if (!gba->stopCallback) {
|
size_t c;
|
||||||
return;
|
for (c = 0; c < mCoreCallbacksListSize(&gba->coreCallbacks); ++c) {
|
||||||
|
struct mCoreCallbacks* callbacks = mCoreCallbacksListGetPointer(&gba->coreCallbacks, c);
|
||||||
|
if (callbacks->sleep) {
|
||||||
|
callbacks->sleep(callbacks->context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
gba->cpu->nextEvent = gba->cpu->cycles;
|
gba->cpu->nextEvent = gba->cpu->cycles;
|
||||||
gba->stopCallback->stop(gba->stopCallback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GBADebug(struct GBA* gba, uint16_t flags) {
|
void GBADebug(struct GBA* gba, uint16_t flags) {
|
||||||
|
|
|
@ -217,18 +217,16 @@ GameController::GameController(QObject* parent)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Put back
|
m_threadContext.sleepCallback = [](mCoreThread* context) {
|
||||||
/*m_threadContext.stopCallback = [](mCoreThread* context) {
|
|
||||||
if (!context) {
|
if (!context) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
GameController* controller = static_cast<GameController*>(context->userData);
|
GameController* controller = static_cast<GameController*>(context->userData);
|
||||||
if (!mCoreSaveState(context->core, 0, controller->m_saveStateFlags)) {
|
if (!mCoreSaveState(context->core, 0, controller->m_saveStateFlags)) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
QMetaObject::invokeMethod(controller, "closeGame");
|
QMetaObject::invokeMethod(controller, "closeGame");
|
||||||
return true;
|
};
|
||||||
};*/
|
|
||||||
|
|
||||||
m_threadContext.logger.d.log = [](mLogger* logger, int category, enum mLogLevel level, const char* format, va_list args) {
|
m_threadContext.logger.d.log = [](mLogger* logger, int category, enum mLogLevel level, const char* format, va_list args) {
|
||||||
mThreadLogger* logContext = reinterpret_cast<mThreadLogger*>(logger);
|
mThreadLogger* logContext = reinterpret_cast<mThreadLogger*>(logger);
|
||||||
|
|
Loading…
Reference in New Issue