all repos — mgba @ 0367a9db067e0c177aae24a0dbdc4e1ad3511668

mGBA Game Boy Advance Emulator

SDL: Properly clean up if a game doesn't launch
Jeffrey Pfau jeffrey@endrift.com
Sun, 25 Jan 2015 03:37:15 -0800
commit

0367a9db067e0c177aae24a0dbdc4e1ad3511668

parent

19eaba3cddda1765839a9f17df08f0fc17e98d5d

2 files changed, 11 insertions(+), 5 deletions(-)

jump to
M CHANGESCHANGES

@@ -29,6 +29,7 @@ - GBA BIOS: Fix BIOS prefetch after reset

- GBA Memory: Fix alignment of open bus 8- and 16-bit loads - GBA Thread: Fix possible hang when loading an archive - Perf: Fix crash when the GBA thread fails to start + - SDL: Properly clean up if a game doesn't launch Misc: - GBA Audio: Change internal audio sample buffer from 32-bit to 16-bit samples - GBA Memory: Simplify memory API and use fixed bus width
M src/platform/sdl/main.csrc/platform/sdl/main.c

@@ -105,12 +105,17 @@ GBASDLInitEvents(&renderer.events);

GBASDLEventsLoadConfig(&renderer.events, &config.configTable); // TODO: Don't use this directly context.overrides = &config.configTable; - GBAThreadStart(&context); - - GBASDLRunloop(&context, &renderer); + int didFail = 0; + if (GBAThreadStart(&context)) { + GBASDLRunloop(&context, &renderer); + GBAThreadJoin(&context); + } else { + didFail = 1; + printf("Could not run game. Are you sure the file exists and is a Game Boy Advance game?\n"); + } - GBAThreadJoin(&context); if (GBAThreadHasCrashed(&context)) { + didFail = 1; printf("The game crashed!\n"); } freeArguments(&args);

@@ -121,7 +126,7 @@ GBAInputMapDeinit(&inputMap);

_GBASDLDeinit(&renderer); - return 0; + return didFail; } static bool _GBASDLInit(struct SDLSoftwareRenderer* renderer) {