SDL: More refactoring

This commit is contained in:
Jeffrey Pfau 2016-02-03 21:13:19 -08:00
parent 1e6f812003
commit dd4b974a0c
1 changed files with 19 additions and 8 deletions

View File

@ -292,16 +292,27 @@ int mSDLRunGB(struct mSDLRenderer* renderer, struct GBAArguments* args) {
renderer->audio.samples = 1024; renderer->audio.samples = 1024;
renderer->audio.sampleRate = 44100; renderer->audio.sampleRate = 44100;
GBSDLInitAudio(&renderer->audio, 0); bool didFail = !GBSDLInitAudio(&renderer->audio, 0);
renderer->audio.sync = &thread.sync; if (!didFail) {
renderer->audio.sync = &thread.sync;
mCoreThreadStart(&thread); if (mCoreThreadStart(&thread)) {
renderer->audio.psg = 0; renderer->audio.psg = 0;
GBSDLResumeAudio(&renderer->audio); GBSDLResumeAudio(&renderer->audio);
renderer->runloop(renderer, &thread); renderer->runloop(renderer, &thread);
mCoreThreadJoin(&thread); mCoreThreadJoin(&thread);
} else {
didFail = true;
printf("Could not run game. Are you sure the file exists and is a Game Boy game?\n");
}
if (mCoreThreadHasCrashed(&thread)) {
didFail = true;
printf("The game crashed!\n");
}
}
renderer->core->unloadROM(renderer->core); renderer->core->unloadROM(renderer->core);
return 0; return didFail;
} }
#endif #endif