all repos — mgba @ 26c1fbd48f574c700ae993eda7de8f37e08c1174

mGBA Game Boy Advance Emulator

Add frame advance
Jeffrey Pfau jeffrey@endrift.com
Mon, 20 Jan 2014 16:39:46 -0800
commit

26c1fbd48f574c700ae993eda7de8f37e08c1174

parent

e7d4f3ae8a1c33a43fc3d73f945c7c7fdefed630

M src/gba/gba-thread.csrc/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.hsrc/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.csrc/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.csrc/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; }