[mGBA] Game Override Sync Settings (#2937)

* override sync settings

* override penguin

* don't override save type when autodetecting

* insert penguin
This commit is contained in:
CasualPokePlayer 2021-09-26 01:55:13 -07:00 committed by GitHub
parent bff6126c1b
commit 4303d1c333
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 95 additions and 46 deletions

Binary file not shown.

Binary file not shown.

View File

@ -56,9 +56,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
LightSensor = 4,
Gyro = 8,
Tilt = 16,
GbPlayer = 32,
GbPlayer = 32, // we're not dolphin, so let's ignore this
GbPlayerDetect = 64,
NoOverride = 0x8000 // can probably ignore this
// heuristics since core only has a builtin autodetect for ALL hardware
// probably will be annoying to update as core adds in more hardware...
AutodetectRtc = 128,
AutodetectRumble = 256,
AutodetectLightSensor = 512,
AutodetectGyro = 1024,
AutodetectTilt = 2048,
// no autodetection for GbPlayerDetect....
}
[Flags]

View File

@ -165,6 +165,47 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
[DefaultValue(typeof(DateTime), "2010-01-01")]
public DateTime RTCInitialTime { get; set; }
[DisplayName("Save Type")]
[Description("Save type used in games.")]
[DefaultValue(LibmGBA.SaveType.Autodetect)]
public LibmGBA.SaveType OverrideSaveType { get; set; }
public enum HardwareSelection : int
{
Autodetect = 0,
True = 1,
False = 2,
}
[DisplayName("RTC")]
[Description("")]
[DefaultValue(HardwareSelection.Autodetect)]
public HardwareSelection OverrideRtc { get; set; }
[DisplayName("Rumble")]
[Description("")]
[DefaultValue(HardwareSelection.Autodetect)]
public HardwareSelection OverrideRumble { get; set; }
[DisplayName("Light Sensor")]
[Description("")]
[DefaultValue(HardwareSelection.Autodetect)]
public HardwareSelection OverrideLightSensor { get; set; }
[DisplayName("Gyro")]
[Description("")]
[DefaultValue(HardwareSelection.Autodetect)]
public HardwareSelection OverrideGyro { get; set; }
[DisplayName("Tilt")]
[Description("")]
[DefaultValue(HardwareSelection.Autodetect)]
public HardwareSelection OverrideTilt { get; set; }
[DisplayName("GB Player Detection")]
[Description("")]
[DefaultValue(false)]
public bool OverrideGbPlayerDetect { get; set; }
public SyncSettings()
{
SettingsUtil.SetDefaultValues(this);

View File

@ -50,7 +50,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
var skipBios = !DeterministicEmulation && _syncSettings.SkipBios;
Core = LibmGBA.BizCreate(bios, file, file.Length, GetOverrideInfo(game), skipBios);
Core = LibmGBA.BizCreate(bios, file, file.Length, GetOverrideInfo(_syncSettings), skipBios);
if (Core == IntPtr.Zero)
{
throw new InvalidOperationException($"{nameof(LibmGBA.BizCreate)}() returned NULL! Bad BIOS? and/or ROM?");
@ -184,61 +184,62 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
private readonly byte[] _saveScratch = new byte[262144];
internal IntPtr Core;
private static LibmGBA.OverrideInfo GetOverrideInfo(GameInfo game)
private static LibmGBA.OverrideInfo GetOverrideInfo(SyncSettings syncSettings)
{
if (!game.OptionPresent("mgbaNeedsOverrides"))
var ret = new LibmGBA.OverrideInfo
{
// 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;
}
Savetype = syncSettings.OverrideSaveType,
Hardware = LibmGBA.Hardware.None
};
var ret = new LibmGBA.OverrideInfo();
if (game.OptionPresent("flashSize"))
if (syncSettings.OverrideRtc is SyncSettings.HardwareSelection.Autodetect)
{
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");
}
ret.Hardware |= LibmGBA.Hardware.AutodetectRtc;
}
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)
else if (syncSettings.OverrideRtc is SyncSettings.HardwareSelection.True)
{
ret.Hardware |= LibmGBA.Hardware.Rtc;
}
if (game.GetInt("mirroringEnabled", 0) == 1)
if (syncSettings.OverrideRumble is SyncSettings.HardwareSelection.Autodetect)
{
throw new InvalidOperationException("Don't know what to do with mirroringEnabled!");
ret.Hardware |= LibmGBA.Hardware.AutodetectRumble;
}
else if (syncSettings.OverrideRumble is SyncSettings.HardwareSelection.True)
{
ret.Hardware |= LibmGBA.Hardware.Rumble;
}
if (game.OptionPresent("idleLoop"))
if (syncSettings.OverrideLightSensor is SyncSettings.HardwareSelection.Autodetect)
{
ret.IdleLoop = (uint)game.GetHexValue("idleLoop");
ret.Hardware |= LibmGBA.Hardware.AutodetectLightSensor;
}
else if (syncSettings.OverrideLightSensor is SyncSettings.HardwareSelection.True)
{
ret.Hardware |= LibmGBA.Hardware.LightSensor;
}
if (syncSettings.OverrideGyro is SyncSettings.HardwareSelection.Autodetect)
{
ret.Hardware |= LibmGBA.Hardware.AutodetectGyro;
}
else if (syncSettings.OverrideGyro is SyncSettings.HardwareSelection.True)
{
ret.Hardware |= LibmGBA.Hardware.Gyro;
}
if (syncSettings.OverrideTilt is SyncSettings.HardwareSelection.Autodetect)
{
ret.Hardware |= LibmGBA.Hardware.AutodetectTilt;
}
else if (syncSettings.OverrideTilt is SyncSettings.HardwareSelection.True)
{
ret.Hardware |= LibmGBA.Hardware.Tilt;
}
if (syncSettings.OverrideGbPlayerDetect is true)
{
ret.Hardware |= LibmGBA.Hardware.GbPlayerDetect;
}
return ret;

@ -1 +1 @@
Subproject commit ade176cfbaca2903ab40d998287f9eb1e84624b5
Subproject commit 4c313a04bfaf0d50e78377324f5425022668b32e