Add frame advance
Jeffrey Pfau jeffrey@endrift.com
Mon, 20 Jan 2014 16:39:46 -0800
4 files changed,
19 insertions(+),
0 deletions(-)
M
src/gba/gba-thread.c
→
src/gba/gba-thread.c
@@ -291,6 +291,11 @@ ConditionWait(&sync->videoFrameRequiredCond, &sync->videoFrameMutex);
} } MutexUnlock(&sync->videoFrameMutex); + + struct GBAThread* thread = GBAThreadGetContext(); + if (thread->frameCallback) { + thread->frameCallback(thread); + } } int GBASyncWaitFrameStart(struct GBASync* sync, int frameskip) {
M
src/gba/gba-thread.h
→
src/gba/gba-thread.h
@@ -36,6 +36,7 @@ Condition stateCond;
ThreadCallback startCallback; ThreadCallback cleanCallback; + ThreadCallback frameCallback; void* userData; struct GBASync {
M
src/platform/sdl/gl-main.c
→
src/platform/sdl/gl-main.c
@@ -73,6 +73,7 @@ context.sync.videoFrameWait = 0;
context.sync.audioWait = 1; context.startCallback = _GBASDLStart; context.cleanCallback = _GBASDLClean; + context.frameCallback = 0; context.userData = &renderer; GBAThreadStart(&context);
M
src/platform/sdl/sdl-events.c
→
src/platform/sdl/sdl-events.c
@@ -11,12 +11,18 @@ return 0;
} SDL_JoystickEventState(SDL_ENABLE); context->joystick = SDL_JoystickOpen(0); + SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); return 1; } void GBASDLDeinitEvents(struct GBASDLEvents* context) { SDL_JoystickClose(context->joystick); 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) {@@ -68,6 +74,12 @@ if (event->keysym.mod & KMOD_CTRL) {
switch (event->keysym.sym) { case SDLK_p: GBAThreadTogglePause(context); + break; + case SDLK_n: + GBAThreadPause(context); + context->frameCallback = _pauseAfterFrame; + GBAThreadUnpause(context); + break; default: break; }