diff --git a/CHANGES b/CHANGES index 6a33406ae..6c53e7a39 100644 --- a/CHANGES +++ b/CHANGES @@ -29,6 +29,7 @@ Bugfixes: - 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 diff --git a/src/platform/sdl/main.c b/src/platform/sdl/main.c index 50331adb1..e43f65f4f 100644 --- a/src/platform/sdl/main.c +++ b/src/platform/sdl/main.c @@ -105,12 +105,17 @@ int main(int argc, char** argv) { GBASDLEventsLoadConfig(&renderer.events, &config.configTable); // TODO: Don't use this directly context.overrides = &config.configTable; - GBAThreadStart(&context); + 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"); + } - GBASDLRunloop(&context, &renderer); - - GBAThreadJoin(&context); if (GBAThreadHasCrashed(&context)) { + didFail = 1; printf("The game crashed!\n"); } freeArguments(&args); @@ -121,7 +126,7 @@ int main(int argc, char** argv) { _GBASDLDeinit(&renderer); - return 0; + return didFail; } static bool _GBASDLInit(struct SDLSoftwareRenderer* renderer) {