gambatte: throw unsupportedmapperexception when appropriate. libsnes: throw cgbexception when trying to load cgb only game in sgb
This commit is contained in:
parent
a8d6d71505
commit
56467334b3
|
@ -225,7 +225,7 @@ namespace BizHawk.Client.Common
|
|||
case "GEN":
|
||||
var genesis = new GPGX(
|
||||
nextComm, null, disc, "GEN", GetCoreSettings<GPGX>(), GetCoreSyncSettings<GPGX>());
|
||||
nextEmulator = genesis;
|
||||
nextEmulator = genesis;
|
||||
break;
|
||||
case "SAT":
|
||||
nextEmulator = new Yabause(nextComm, disc, GetCoreSyncSettings<Yabause>());
|
||||
|
@ -318,11 +318,10 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
// need to get rid of this hack at some point
|
||||
((CoreFileProvider)nextComm.CoreFileProvider).SubfileDirectory = Path.GetDirectoryName(path.Replace("|", String.Empty)); // Dirty hack to get around archive filenames (since we are just getting the directory path, it is safe to mangle the filename
|
||||
var snes = new LibsnesCore(nextComm, GetCoreSettings<LibsnesCore>(), GetCoreSyncSettings<LibsnesCore>());
|
||||
nextEmulator = snes;
|
||||
var romData = isXml ? null : rom.FileData;
|
||||
var xmlData = isXml ? rom.FileData : null;
|
||||
snes.Load(game, romData, Deterministic, xmlData);
|
||||
var snes = new LibsnesCore(game, romData, Deterministic, xmlData, nextComm, GetCoreSettings<LibsnesCore>(), GetCoreSyncSettings<LibsnesCore>());
|
||||
nextEmulator = snes;
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -333,8 +332,8 @@ namespace BizHawk.Client.Common
|
|||
break;
|
||||
case "A26":
|
||||
nextEmulator = new Atari2600(
|
||||
nextComm,
|
||||
game,
|
||||
nextComm,
|
||||
game,
|
||||
rom.FileData,
|
||||
GetCoreSettings<Atari2600>(),
|
||||
GetCoreSyncSettings<Atari2600>());
|
||||
|
@ -384,9 +383,8 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
game.System = "SNES";
|
||||
game.AddOption("SGB");
|
||||
var snes = new LibsnesCore(nextComm, GetCoreSettings<LibsnesCore>(), GetCoreSyncSettings<LibsnesCore>());
|
||||
var snes = new LibsnesCore(game, rom.FileData, Deterministic, null, nextComm, GetCoreSettings<LibsnesCore>(), GetCoreSyncSettings<LibsnesCore>());
|
||||
nextEmulator = snes;
|
||||
snes.Load(game, rom.FileData, Deterministic, null);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -450,7 +448,7 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
// Specific hack here, as we get more cores of the same system, this isn't scalable
|
||||
if (ex is LibQuickNES.UnsupportedMapperException)
|
||||
if (ex is UnsupportedMapperException)
|
||||
{
|
||||
return LoadRom(path, nextComm, forceAccurateCore: true);
|
||||
}
|
||||
|
@ -473,4 +471,4 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,4 +9,26 @@ namespace BizHawk.Emulation.Common
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
public class UnsupportedMapperException : InvalidOperationException
|
||||
{
|
||||
public UnsupportedMapperException(string message)
|
||||
: base(message)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class CGBNotSupportedException : Exception
|
||||
{
|
||||
public CGBNotSupportedException()
|
||||
: base("Core does not support CGB only games!")
|
||||
{
|
||||
}
|
||||
|
||||
public CGBNotSupportedException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
GambatteState = LibGambatte.gambatte_create();
|
||||
|
||||
if (GambatteState == IntPtr.Zero)
|
||||
throw new Exception("gambatte_create() returned null???");
|
||||
throw new InvalidOperationException("gambatte_create() returned null???");
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -128,7 +128,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
flags |= LibGambatte.LoadFlags.MULTICART_COMPAT;
|
||||
|
||||
if (LibGambatte.gambatte_load(GambatteState, romdata, (uint)romdata.Length, GetCurrentTime(), flags) != 0)
|
||||
throw new Exception("gambatte_load() returned non-zero (is this not a gb or gbc rom?)");
|
||||
throw new InvalidOperationException("gambatte_load() returned non-zero (is this not a gb or gbc rom?)");
|
||||
|
||||
// set real default colors (before anyone mucks with them at all)
|
||||
PutSettings(Settings ?? new GambatteSettings());
|
||||
|
@ -352,7 +352,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
static void ThrowExceptionForBadRom(byte[] romdata)
|
||||
{
|
||||
if (romdata.Length < 0x148)
|
||||
throw new Exception("ROM is far too small to be a valid GB\\GBC rom!");
|
||||
throw new ArgumentException("ROM is far too small to be a valid GB\\GBC rom!");
|
||||
|
||||
switch (romdata[0x147])
|
||||
{
|
||||
|
@ -365,9 +365,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
case 0x08: break;
|
||||
case 0x09: break;
|
||||
|
||||
case 0x0b: throw new Exception("\"MM01\" Mapper not supported!");
|
||||
case 0x0c: throw new Exception("\"MM01\" Mapper not supported!");
|
||||
case 0x0d: throw new Exception("\"MM01\" Mapper not supported!");
|
||||
case 0x0b: throw new UnsupportedMapperException("\"MM01\" Mapper not supported!");
|
||||
case 0x0c: throw new UnsupportedMapperException("\"MM01\" Mapper not supported!");
|
||||
case 0x0d: throw new UnsupportedMapperException("\"MM01\" Mapper not supported!");
|
||||
|
||||
case 0x0f: break;
|
||||
case 0x10: break;
|
||||
|
@ -375,9 +375,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
case 0x12: break;
|
||||
case 0x13: break;
|
||||
|
||||
case 0x15: throw new Exception("\"MBC4\" Mapper not supported!");
|
||||
case 0x16: throw new Exception("\"MBC4\" Mapper not supported!");
|
||||
case 0x17: throw new Exception("\"MBC4\" Mapper not supported!");
|
||||
case 0x15: throw new UnsupportedMapperException("\"MBC4\" Mapper not supported!");
|
||||
case 0x16: throw new UnsupportedMapperException("\"MBC4\" Mapper not supported!");
|
||||
case 0x17: throw new UnsupportedMapperException("\"MBC4\" Mapper not supported!");
|
||||
|
||||
case 0x19: break;
|
||||
case 0x1a: break;
|
||||
|
@ -386,14 +386,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
case 0x1d: break; // rumble
|
||||
case 0x1e: break; // rumble
|
||||
|
||||
case 0x20: throw new Exception("\"MBC6\" Mapper not supported!");
|
||||
case 0x22: throw new Exception("\"MBC7\" Mapper not supported!");
|
||||
case 0x20: throw new UnsupportedMapperException("\"MBC6\" Mapper not supported!");
|
||||
case 0x22: throw new UnsupportedMapperException("\"MBC7\" Mapper not supported!");
|
||||
|
||||
case 0xfc: throw new Exception("\"Pocket Camera\" Mapper not supported!");
|
||||
case 0xfd: throw new Exception("\"Bandai TAMA5\" Mapper not supported!");
|
||||
case 0xfe: throw new Exception("\"HuC3\" Mapper not supported!");
|
||||
case 0xfc: throw new UnsupportedMapperException("\"Pocket Camera\" Mapper not supported!");
|
||||
case 0xfd: throw new UnsupportedMapperException("\"Bandai TAMA5\" Mapper not supported!");
|
||||
case 0xfe: throw new UnsupportedMapperException("\"HuC3\" Mapper not supported!");
|
||||
case 0xff: break;
|
||||
default: throw new Exception(string.Format("Unknown mapper: {0:x2}", romdata[0x147]));
|
||||
default: throw new UnsupportedMapperException(string.Format("Unknown mapper: {0:x2}", romdata[0x147]));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -215,15 +215,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
|||
[DllImport(dllname, CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr qn_get_mapper(IntPtr e, ref int number);
|
||||
|
||||
public class UnsupportedMapperException : InvalidOperationException
|
||||
{
|
||||
public UnsupportedMapperException(string message)
|
||||
: base(message)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// handle "string error" as returned by some quicknes functions
|
||||
/// </summary>
|
||||
|
@ -235,7 +226,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
|||
string s = Marshal.PtrToStringAnsi(p);
|
||||
if (s == "Unsupported mapper" || s == "Not an iNES file") // Not worth making a new exception for the iNES error, they ultimately are the same problem
|
||||
{
|
||||
throw new UnsupportedMapperException("Quicknes unsupported mapper");
|
||||
throw new Emulation.Common.UnsupportedMapperException("Quicknes unsupported mapper");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -259,19 +259,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
return exePath;
|
||||
}
|
||||
|
||||
public LibsnesCore(CoreComm comm, object Settings, object SyncSettings)
|
||||
{
|
||||
this.Settings = (SnesSettings)Settings ?? new SnesSettings();
|
||||
this.SyncSettings = (SnesSyncSettings)SyncSettings ?? new SnesSyncSettings();
|
||||
CoreComm = comm;
|
||||
|
||||
api = new LibsnesApi(GetExePath());
|
||||
api.CMD_init();
|
||||
api.ReadHook = ReadHook;
|
||||
api.ExecHook = ExecHook;
|
||||
api.WriteHook = WriteHook;
|
||||
}
|
||||
|
||||
void ReadHook(uint addr)
|
||||
{
|
||||
CoreComm.MemoryCallbackSystem.CallRead(addr);
|
||||
|
@ -327,15 +314,27 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
else return api.CMD_load_cartridge_super_game_boy(CurrLoadParams.rom_xml, CurrLoadParams.rom_data, CurrLoadParams.rom_size, CurrLoadParams.dmg_xml, CurrLoadParams.dmg_data, CurrLoadParams.dmg_size);
|
||||
}
|
||||
|
||||
public void Load(GameInfo game, byte[] romData, bool deterministicEmulation, byte[] xmlData)
|
||||
public LibsnesCore(GameInfo game, byte[] romData, bool deterministicEmulation, byte[] xmlData, CoreComm comm, object Settings, object SyncSettings)
|
||||
{
|
||||
byte[] sgbRomData = null;
|
||||
if (game["SGB"])
|
||||
{
|
||||
if ((romData[0x143] & 0xc0) == 0xc0)
|
||||
throw new CGBNotSupportedException();
|
||||
sgbRomData = CoreComm.CoreFileProvider.GetFirmware("SNES", "Rom_SGB", true, "SGB Rom is required for SGB emulation.");
|
||||
game.FirmwareHash = sgbRomData.HashSHA1();
|
||||
}
|
||||
|
||||
|
||||
this.Settings = (SnesSettings)Settings ?? new SnesSettings();
|
||||
this.SyncSettings = (SnesSyncSettings)SyncSettings ?? new SnesSyncSettings();
|
||||
CoreComm = comm;
|
||||
|
||||
api = new LibsnesApi(GetExePath());
|
||||
api.CMD_init();
|
||||
api.ReadHook = ReadHook;
|
||||
api.ExecHook = ExecHook;
|
||||
api.WriteHook = WriteHook;
|
||||
|
||||
ScanlineHookManager = new MyScanlineHookManager(this);
|
||||
|
||||
api.CMD_init();
|
||||
|
|
Loading…
Reference in New Issue