Make debugger optional

This commit is contained in:
Jeffrey Pfau 2013-09-21 18:10:13 -07:00
parent 9d10ca3f90
commit e80ab4c855
4 changed files with 22 additions and 6 deletions

View File

@ -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;

View File

@ -6,6 +6,7 @@
struct GBAThread {
// Output
int started;
int useDebugger;
struct GBA* gba;
struct ARMDebugger* debugger;

View File

@ -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;

View File

@ -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: