mirror of https://github.com/mgba-emu/mgba.git
Make debugger optional
This commit is contained in:
parent
9d10ca3f90
commit
e80ab4c855
|
@ -21,11 +21,15 @@ static void* _GBAThreadRun(void* context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
threadContext->gba = &gba;
|
threadContext->gba = &gba;
|
||||||
threadContext->debugger = &debugger;
|
|
||||||
if (threadContext->fd >= 0) {
|
if (threadContext->fd >= 0) {
|
||||||
GBALoadROM(&gba, threadContext->fd);
|
GBALoadROM(&gba, threadContext->fd);
|
||||||
}
|
}
|
||||||
GBAAttachDebugger(&gba, &debugger);
|
if (threadContext->useDebugger) {
|
||||||
|
threadContext->debugger = &debugger;
|
||||||
|
GBAAttachDebugger(&gba, &debugger);
|
||||||
|
} else {
|
||||||
|
threadContext->debugger = 0;
|
||||||
|
}
|
||||||
gba.keySource = &threadContext->activeKeys;
|
gba.keySource = &threadContext->activeKeys;
|
||||||
|
|
||||||
threadContext->started = 1;
|
threadContext->started = 1;
|
||||||
|
@ -33,8 +37,14 @@ static void* _GBAThreadRun(void* context) {
|
||||||
pthread_cond_broadcast(&threadContext->cond);
|
pthread_cond_broadcast(&threadContext->cond);
|
||||||
pthread_mutex_unlock(&threadContext->mutex);
|
pthread_mutex_unlock(&threadContext->mutex);
|
||||||
|
|
||||||
ARMDebuggerRun(&debugger);
|
if (threadContext->useDebugger) {
|
||||||
threadContext->started = 0;
|
ARMDebuggerRun(&debugger);
|
||||||
|
threadContext->started = 0;
|
||||||
|
} else {
|
||||||
|
while (threadContext->started) {
|
||||||
|
ARMRun(&gba.cpu);
|
||||||
|
}
|
||||||
|
}
|
||||||
GBADeinit(&gba);
|
GBADeinit(&gba);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
struct GBAThread {
|
struct GBAThread {
|
||||||
// Output
|
// Output
|
||||||
int started;
|
int started;
|
||||||
|
int useDebugger;
|
||||||
struct GBA* gba;
|
struct GBA* gba;
|
||||||
struct ARMDebugger* debugger;
|
struct ARMDebugger* debugger;
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@ int main(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
context.fd = fd;
|
context.fd = fd;
|
||||||
|
context.useDebugger = 0;
|
||||||
context.renderer = &renderer.d.d;
|
context.renderer = &renderer.d.d;
|
||||||
GBAThreadStart(&context);
|
GBAThreadStart(&context);
|
||||||
|
|
||||||
|
@ -118,7 +119,7 @@ static void _GBASDLRunloop(struct GBAThread* context, struct GLSoftwareRenderer*
|
||||||
glMatrixMode (GL_PROJECTION);
|
glMatrixMode (GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glOrtho(0, 240, 160, 0, 0, 1);
|
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);
|
pthread_mutex_lock(&renderer->d.mutex);
|
||||||
if (renderer->d.d.framesPending) {
|
if (renderer->d.d.framesPending) {
|
||||||
renderer->d.d.framesPending = 0;
|
renderer->d.d.framesPending = 0;
|
||||||
|
|
|
@ -121,7 +121,11 @@ void GBASDLHandleEvent(struct GBAThread* context, const union SDL_Event* event)
|
||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
// FIXME: this isn't thread-safe
|
// FIXME: this isn't thread-safe
|
||||||
context->debugger->state = DEBUGGER_EXITING;
|
if (context->debugger) {
|
||||||
|
context->debugger->state = DEBUGGER_EXITING;
|
||||||
|
} else {
|
||||||
|
context->started = 0;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
|
|
Loading…
Reference in New Issue