Rom Loader - Catch CGBNotSupportedException and output a message to the screen, then automatically reload the rom in regular mode

This commit is contained in:
adelikat 2014-08-02 02:41:12 +00:00
parent 9cfb30093a
commit 93b71373eb
2 changed files with 21 additions and 3 deletions

View File

@ -61,6 +61,17 @@ namespace BizHawk.Client.Common
} }
// For not throwing errors but simply outputing information to the screen
public Action<string> MessageCallback { get; set; }
private void DoMessageCallback(string message)
{
if (MessageCallback != null)
{
MessageCallback(message);
}
}
// TODO: reconsider the need for exposing these; // TODO: reconsider the need for exposing these;
public IEmulator LoadedEmulator { get; private set; } public IEmulator LoadedEmulator { get; private set; }
public GameInfo Game { get; private set; } public GameInfo Game { get; private set; }
@ -388,8 +399,8 @@ namespace BizHawk.Client.Common
} }
catch catch
{ {
// failed to load SGB bios. to avoid catch-22, disable SGB mode // failed to load SGB bios or game does not support SGB mode.
DoLoadErrorCallback("Failed to load a GB rom in SGB mode. Disabling SGB Mode.", game.System); // To avoid catch-22, disable SGB mode
Global.Config.GB_AsSGB = false; Global.Config.GB_AsSGB = false;
throw; throw;
} }
@ -456,6 +467,12 @@ namespace BizHawk.Client.Common
{ {
DoLoadErrorCallback(ex.Message, system, LoadErrorType.MissingFirmware); DoLoadErrorCallback(ex.Message, system, LoadErrorType.MissingFirmware);
} }
else if (ex is CGBNotSupportedException)
{
// Note: GB as SGB was set to false by this point, otherwise we would want to do it here
DoMessageCallback("Failed to load a GB rom in SGB mode. Disabling SGB Mode.");
return LoadRom(path, nextComm);
}
else else
{ {
DoLoadErrorCallback("A core accepted the rom, but threw an exception while loading it:\n\n" + ex, system); DoLoadErrorCallback("A core accepted the rom, but threw an exception while loading it:\n\n" + ex, system);

View File

@ -3089,7 +3089,8 @@ namespace BizHawk.Client.EmuHawk
{ {
ChooseArchive = LoadArhiveChooser, ChooseArchive = LoadArhiveChooser,
ChoosePlatform = ChoosePlatformForRom, ChoosePlatform = ChoosePlatformForRom,
Deterministic = deterministic Deterministic = deterministic,
MessageCallback = GlobalWin.OSD.AddMessage
}; };
loader.OnLoadError += ShowLoadError; loader.OnLoadError += ShowLoadError;