all repos — mgba @ e80ab4c855ef1d3c2e320b2a21b72b9fc1de74a4

mGBA Game Boy Advance Emulator

Make debugger optional
Jeffrey Pfau jeffrey@endrift.com
Sat, 21 Sep 2013 18:10:13 -0700
commit

e80ab4c855ef1d3c2e320b2a21b72b9fc1de74a4

parent

9d10ca3f90b0ff08a8d84e31f338dad17c91eab2

4 files changed, 22 insertions(+), 6 deletions(-)

jump to
M src/gba/gba-thread.csrc/gba/gba-thread.c

@@ -21,11 +21,15 @@ GBAVideoAssociateRenderer(&gba.video, threadContext->renderer);

} 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 @@ pthread_mutex_lock(&threadContext->mutex);

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

@@ -6,6 +6,7 @@

struct GBAThread { // Output int started; + int useDebugger; struct GBA* gba; struct ARMDebugger* debugger;
M src/gl-main.csrc/gl-main.c

@@ -65,6 +65,7 @@ return 1;

} context.fd = fd; + context.useDebugger = 0; context.renderer = &renderer.d.d; GBAThreadStart(&context);

@@ -118,7 +119,7 @@ glTexCoordPointer(2, GL_INT, 0, _glTexCoords);

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;
M src/sdl/sdl-events.csrc/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: