SDL: More refactoring
Jeffrey Pfau jeffrey@endrift.com
Wed, 03 Feb 2016 21:13:19 -0800
1 files changed,
19 insertions(+),
8 deletions(-)
jump to
M
src/platform/sdl/main.c
→
src/platform/sdl/main.c
@@ -292,16 +292,27 @@
renderer->audio.samples = 1024; renderer->audio.sampleRate = 44100; - GBSDLInitAudio(&renderer->audio, 0); - renderer->audio.sync = &thread.sync; + bool didFail = !GBSDLInitAudio(&renderer->audio, 0); + if (!didFail) { + renderer->audio.sync = &thread.sync; + + if (mCoreThreadStart(&thread)) { + renderer->audio.psg = 0; + GBSDLResumeAudio(&renderer->audio); + renderer->runloop(renderer, &thread); + mCoreThreadJoin(&thread); + } else { + didFail = true; + printf("Could not run game. Are you sure the file exists and is a Game Boy game?\n"); + } - mCoreThreadStart(&thread); - renderer->audio.psg = 0; - GBSDLResumeAudio(&renderer->audio); - renderer->runloop(renderer, &thread); - mCoreThreadJoin(&thread); + if (mCoreThreadHasCrashed(&thread)) { + didFail = true; + printf("The game crashed!\n"); + } + } renderer->core->unloadROM(renderer->core); - return 0; + return didFail; } #endif