diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.BoardSystem.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.BoardSystem.cs index 35293dccdf..2f65e1ed56 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.BoardSystem.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.BoardSystem.cs @@ -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().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(); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs index b23a20605d..cfb406f06f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs @@ -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