mirror of https://github.com/mgba-emu/mgba.git
Add frame advance
This commit is contained in:
parent
e7d4f3ae8a
commit
26c1fbd48f
|
@ -291,6 +291,11 @@ void GBASyncPostFrame(struct GBASync* sync) {
|
|||
}
|
||||
}
|
||||
MutexUnlock(&sync->videoFrameMutex);
|
||||
|
||||
struct GBAThread* thread = GBAThreadGetContext();
|
||||
if (thread->frameCallback) {
|
||||
thread->frameCallback(thread);
|
||||
}
|
||||
}
|
||||
|
||||
int GBASyncWaitFrameStart(struct GBASync* sync, int frameskip) {
|
||||
|
|
|
@ -36,6 +36,7 @@ struct GBAThread {
|
|||
|
||||
ThreadCallback startCallback;
|
||||
ThreadCallback cleanCallback;
|
||||
ThreadCallback frameCallback;
|
||||
void* userData;
|
||||
|
||||
struct GBASync {
|
||||
|
|
|
@ -73,6 +73,7 @@ int main(int argc, char** argv) {
|
|||
context.sync.audioWait = 1;
|
||||
context.startCallback = _GBASDLStart;
|
||||
context.cleanCallback = _GBASDLClean;
|
||||
context.frameCallback = 0;
|
||||
context.userData = &renderer;
|
||||
GBAThreadStart(&context);
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ int GBASDLInitEvents(struct GBASDLEvents* context) {
|
|||
}
|
||||
SDL_JoystickEventState(SDL_ENABLE);
|
||||
context->joystick = SDL_JoystickOpen(0);
|
||||
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -19,6 +20,11 @@ void GBASDLDeinitEvents(struct GBASDLEvents* context) {
|
|||
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
|
||||
}
|
||||
|
||||
static void _pauseAfterFrame(struct GBAThread* context) {
|
||||
context->frameCallback = 0;
|
||||
GBAThreadPause(context);
|
||||
}
|
||||
|
||||
static void _GBASDLHandleKeypress(struct GBAThread* context, const struct SDL_KeyboardEvent* event) {
|
||||
enum GBAKey key = 0;
|
||||
switch (event->keysym.sym) {
|
||||
|
@ -68,6 +74,12 @@ static void _GBASDLHandleKeypress(struct GBAThread* context, const struct SDL_Ke
|
|||
switch (event->keysym.sym) {
|
||||
case SDLK_p:
|
||||
GBAThreadTogglePause(context);
|
||||
break;
|
||||
case SDLK_n:
|
||||
GBAThreadPause(context);
|
||||
context->frameCallback = _pauseAfterFrame;
|
||||
GBAThreadUnpause(context);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue