mgba: Game overrides from gamedb
This commit is contained in:
parent
2ed7c8d474
commit
9b46a6cb3f
|
@ -24,8 +24,41 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
[DllImport(dll, CallingConvention = cc)]
|
||||
public static extern void BizSkipBios(IntPtr ctx);
|
||||
|
||||
public enum SaveType : int
|
||||
{
|
||||
Autodetect = -1,
|
||||
ForceNone = 0,
|
||||
Sram = 1,
|
||||
Flash512 = 2,
|
||||
Flash1m = 3,
|
||||
Eeprom = 4
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum Hardware : int
|
||||
{
|
||||
None = 0,
|
||||
Rtc = 1,
|
||||
Rumble = 2,
|
||||
LightSensor = 4,
|
||||
Gyro = 8,
|
||||
Tilt = 16,
|
||||
GbPlayer = 32,
|
||||
GbPlayerDetect = 64,
|
||||
NoOverride = 0x8000 // can probably ignore this
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class OverrideInfo
|
||||
{
|
||||
public SaveType Savetype;
|
||||
public Hardware Hardware;
|
||||
public uint IdleLoop = IDLE_LOOP_NONE;
|
||||
public const uint IDLE_LOOP_NONE = unchecked((uint)0xffffffff);
|
||||
}
|
||||
|
||||
[DllImport(dll, CallingConvention = cc)]
|
||||
public static extern bool BizLoad(IntPtr ctx, byte[] data, int length);
|
||||
public static extern bool BizLoad(IntPtr ctx, byte[] data, int length, [In]OverrideInfo dbinfo);
|
||||
|
||||
[DllImport(dll, CallingConvention = cc)]
|
||||
public static extern bool BizAdvance(IntPtr ctx, LibVBANext.Buttons keys, int[] vbuff, ref int nsamp, short[] sbuff,
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
IntPtr core;
|
||||
|
||||
[CoreConstructor("GBA")]
|
||||
public MGBAHawk(byte[] file, CoreComm comm, SyncSettings syncSettings, Settings settings, bool deterministic)
|
||||
public MGBAHawk(byte[] file, CoreComm comm, SyncSettings syncSettings, Settings settings, bool deterministic, GameInfo game)
|
||||
{
|
||||
_syncSettings = syncSettings ?? new SyncSettings();
|
||||
_settings = settings ?? new Settings();
|
||||
|
@ -47,7 +47,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
}
|
||||
try
|
||||
{
|
||||
if (!LibmGBA.BizLoad(core, file, file.Length))
|
||||
if (!LibmGBA.BizLoad(core, file, file.Length, GetOverrideInfo(game)))
|
||||
{
|
||||
throw new InvalidOperationException("BizLoad() returned FALSE! Bad ROM?");
|
||||
}
|
||||
|
@ -80,6 +80,53 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
}
|
||||
}
|
||||
|
||||
private static LibmGBA.OverrideInfo GetOverrideInfo(GameInfo game)
|
||||
{
|
||||
if (!game.OptionPresent("mgbaNeedsOverrides"))
|
||||
{
|
||||
// the gba game db predates the mgba core in bizhawk, but was never used by the mgba core,
|
||||
// which had its own handling for overrides
|
||||
// to avoid possible regressions, we don't want to be overriding things that we already
|
||||
// know work in mgba, so unless this parameter is set, we do nothing
|
||||
return null;
|
||||
}
|
||||
|
||||
var ret = new LibmGBA.OverrideInfo();
|
||||
if (game.OptionPresent("flashSize"))
|
||||
{
|
||||
switch (game.GetIntValue("flashSize"))
|
||||
{
|
||||
case 65536: ret.Savetype = LibmGBA.SaveType.Flash512; break;
|
||||
case 131072: ret.Savetype = LibmGBA.SaveType.Flash1m; break;
|
||||
default: throw new InvalidOperationException("Unknown flashSize");
|
||||
}
|
||||
}
|
||||
else if (game.OptionPresent("saveType"))
|
||||
{
|
||||
switch (game.GetIntValue("saveType"))
|
||||
{
|
||||
// 3 specifies either flash 512 or 1024, but in vba-over.ini, the latter will have a flashSize as well
|
||||
case 3: ret.Savetype = LibmGBA.SaveType.Flash512; break;
|
||||
case 4: ret.Savetype = LibmGBA.SaveType.Eeprom; break;
|
||||
default: throw new InvalidOperationException("Unknown saveType");
|
||||
}
|
||||
}
|
||||
|
||||
if (game.GetInt("rtcEnabled", 0) == 1)
|
||||
{
|
||||
ret.Hardware |= LibmGBA.Hardware.Rtc;
|
||||
}
|
||||
if (game.GetInt("mirroringEnabled", 0) == 1)
|
||||
{
|
||||
throw new InvalidOperationException("Don't know what to do with mirroringEnabled!");
|
||||
}
|
||||
if (game.OptionPresent("idleLoop"))
|
||||
{
|
||||
ret.IdleLoop = (uint)game.GetHexValue("idleLoop");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
MemoryDomainList MemoryDomains;
|
||||
|
||||
public IEmulatorServiceProvider ServiceProvider { get; private set; }
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue