Populate board values sync settings with default values when loading a game on a board with them

This commit is contained in:
nattthebear 2015-08-05 20:55:35 -04:00
parent 76f285a58a
commit 4f159b4c20
2 changed files with 19 additions and 0 deletions

View File

@ -729,6 +729,22 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public static class AutoMapperProps
{
public static void Populate(NES.INESBoard board, NES.NESSyncSettings settings)
{
var fields = board.GetType().GetFields();
foreach (var field in fields)
{
var attrib = field.GetCustomAttributes(typeof(MapperPropAttribute), false).OfType<MapperPropAttribute>().SingleOrDefault();
if (attrib == null)
continue;
string Name = attrib.Name ?? field.Name;
if (!settings.BoardProperties.ContainsKey(Name))
{
settings.BoardProperties.Add(Name, (string)Convert.ChangeType(field.GetValue(board), typeof(string)));
}
}
}
public static void Apply(NES.INESBoard board)
{
var fields = board.GetType().GetFields();

View File

@ -426,6 +426,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
nsfboard.WRAM = new byte[cart.wram_size * 1024];
Board = nsfboard;
Board.PostConfigure();
AutoMapperProps.Populate(Board, SyncSettings);
Console.WriteLine("Using NTSC display type for NSF for now");
_display_type = Common.DisplayType.NTSC;
@ -463,6 +464,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
Board.VRAM = new byte[cart.vram_size * 1024];
Board.PostConfigure();
AutoMapperProps.Populate(Board, SyncSettings);
Console.WriteLine("Using NTSC display type for FDS disk image");
_display_type = Common.DisplayType.NTSC;
@ -709,6 +711,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
Board.VRAM = new byte[cart.vram_size * 1024];
Board.PostConfigure();
AutoMapperProps.Populate(Board, SyncSettings);
// set up display type