all repos — mgba @ dd4b974a0c46b041fa7d4cea88f06af8f7f798a6

mGBA Game Boy Advance Emulator

SDL: More refactoring
Jeffrey Pfau jeffrey@endrift.com
Wed, 03 Feb 2016 21:13:19 -0800
commit

dd4b974a0c46b041fa7d4cea88f06af8f7f798a6

parent

1e6f812003d145725ce65c72feba612dd11dce66

1 files changed, 19 insertions(+), 8 deletions(-)

jump to
M src/platform/sdl/main.csrc/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