mirror of https://github.com/mgba-emu/mgba.git
SDL: Properly check for initialization
This commit is contained in:
parent
f2e298f78d
commit
d09d0e505f
1
CHANGES
1
CHANGES
|
@ -66,6 +66,7 @@ Misc:
|
||||||
- GBA: SIO logging layer
|
- GBA: SIO logging layer
|
||||||
- Qt: Add application icon and XDG desktop files
|
- Qt: Add application icon and XDG desktop files
|
||||||
- GBA Thread: Split GBASync into a separate file
|
- GBA Thread: Split GBASync into a separate file
|
||||||
|
- SDL: Properly check for initialization
|
||||||
|
|
||||||
0.2.1: (2015-05-13)
|
0.2.1: (2015-05-13)
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
|
|
@ -107,8 +107,12 @@ int main(int argc, char** argv) {
|
||||||
GBAMapOptionsToContext(&opts, &context);
|
GBAMapOptionsToContext(&opts, &context);
|
||||||
GBAMapArgumentsToContext(&args, &context);
|
GBAMapArgumentsToContext(&args, &context);
|
||||||
|
|
||||||
|
bool didFail = false;
|
||||||
|
|
||||||
renderer.audio.samples = context.audioBuffers;
|
renderer.audio.samples = context.audioBuffers;
|
||||||
GBASDLInitAudio(&renderer.audio, &context);
|
if (!GBASDLInitAudio(&renderer.audio, &context)) {
|
||||||
|
didFail = true;
|
||||||
|
}
|
||||||
|
|
||||||
renderer.player.bindings = &inputMap;
|
renderer.player.bindings = &inputMap;
|
||||||
GBASDLInitBindings(&inputMap);
|
GBASDLInitBindings(&inputMap);
|
||||||
|
@ -118,28 +122,28 @@ int main(int argc, char** argv) {
|
||||||
GBASDLPlayerLoadConfig(&renderer.player, GBAConfigGetInput(&config));
|
GBASDLPlayerLoadConfig(&renderer.player, GBAConfigGetInput(&config));
|
||||||
context.overrides = GBAConfigGetOverrides(&config);
|
context.overrides = GBAConfigGetOverrides(&config);
|
||||||
|
|
||||||
|
if (!didFail) {
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
GBASDLSetScreensaverSuspendable(&renderer.events, opts.suspendScreensaver);
|
GBASDLSetScreensaverSuspendable(&renderer.events, opts.suspendScreensaver);
|
||||||
GBASDLSuspendScreensaver(&renderer.events);
|
GBASDLSuspendScreensaver(&renderer.events);
|
||||||
#endif
|
#endif
|
||||||
|
if (GBAThreadStart(&context)) {
|
||||||
int didFail = 0;
|
renderer.runloop(&context, &renderer);
|
||||||
if (GBAThreadStart(&context)) {
|
GBAThreadJoin(&context);
|
||||||
renderer.runloop(&context, &renderer);
|
} else {
|
||||||
GBAThreadJoin(&context);
|
didFail = true;
|
||||||
} else {
|
printf("Could not run game. Are you sure the file exists and is a Game Boy Advance game?\n");
|
||||||
didFail = 1;
|
}
|
||||||
printf("Could not run game. Are you sure the file exists and is a Game Boy Advance game?\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
GBASDLResumeScreensaver(&renderer.events);
|
GBASDLResumeScreensaver(&renderer.events);
|
||||||
GBASDLSetScreensaverSuspendable(&renderer.events, false);
|
GBASDLSetScreensaverSuspendable(&renderer.events, false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (GBAThreadHasCrashed(&context)) {
|
if (GBAThreadHasCrashed(&context)) {
|
||||||
didFail = 1;
|
didFail = true;
|
||||||
printf("The game crashed!\n");
|
printf("The game crashed!\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
freeArguments(&args);
|
freeArguments(&args);
|
||||||
GBAConfigFreeOpts(&opts);
|
GBAConfigFreeOpts(&opts);
|
||||||
|
|
Loading…
Reference in New Issue