diff --git a/src/gba/gba-thread.c b/src/gba/gba-thread.c index b4072a196..3ffcfc502 100644 --- a/src/gba/gba-thread.c +++ b/src/gba/gba-thread.c @@ -21,11 +21,15 @@ static void* _GBAThreadRun(void* context) { } threadContext->gba = &gba; - threadContext->debugger = &debugger; if (threadContext->fd >= 0) { GBALoadROM(&gba, threadContext->fd); } - GBAAttachDebugger(&gba, &debugger); + if (threadContext->useDebugger) { + threadContext->debugger = &debugger; + GBAAttachDebugger(&gba, &debugger); + } else { + threadContext->debugger = 0; + } gba.keySource = &threadContext->activeKeys; threadContext->started = 1; @@ -33,8 +37,14 @@ static void* _GBAThreadRun(void* context) { pthread_cond_broadcast(&threadContext->cond); pthread_mutex_unlock(&threadContext->mutex); - ARMDebuggerRun(&debugger); - threadContext->started = 0; + if (threadContext->useDebugger) { + ARMDebuggerRun(&debugger); + threadContext->started = 0; + } else { + while (threadContext->started) { + ARMRun(&gba.cpu); + } + } GBADeinit(&gba); return 0; diff --git a/src/gba/gba-thread.h b/src/gba/gba-thread.h index 2270394ec..c1a454f38 100644 --- a/src/gba/gba-thread.h +++ b/src/gba/gba-thread.h @@ -6,6 +6,7 @@ struct GBAThread { // Output int started; + int useDebugger; struct GBA* gba; struct ARMDebugger* debugger; diff --git a/src/gl-main.c b/src/gl-main.c index 3826e1ef9..cc246a822 100644 --- a/src/gl-main.c +++ b/src/gl-main.c @@ -65,6 +65,7 @@ int main(int argc, char** argv) { } context.fd = fd; + context.useDebugger = 0; context.renderer = &renderer.d.d; GBAThreadStart(&context); @@ -118,7 +119,7 @@ static void _GBASDLRunloop(struct GBAThread* context, struct GLSoftwareRenderer* glMatrixMode (GL_PROJECTION); glLoadIdentity(); glOrtho(0, 240, 160, 0, 0, 1); - while (context->started && context->debugger->state != DEBUGGER_EXITING) { + while (context->started && (!context->debugger || context->debugger->state != DEBUGGER_EXITING)) { pthread_mutex_lock(&renderer->d.mutex); if (renderer->d.d.framesPending) { renderer->d.d.framesPending = 0; diff --git a/src/sdl/sdl-events.c b/src/sdl/sdl-events.c index 440c4efe3..c787d2f9a 100644 --- a/src/sdl/sdl-events.c +++ b/src/sdl/sdl-events.c @@ -121,7 +121,11 @@ void GBASDLHandleEvent(struct GBAThread* context, const union SDL_Event* event) switch (event->type) { case SDL_QUIT: // FIXME: this isn't thread-safe - context->debugger->state = DEBUGGER_EXITING; + if (context->debugger) { + context->debugger->state = DEBUGGER_EXITING; + } else { + context->started = 0; + } break; case SDL_KEYDOWN: case SDL_KEYUP: