Populate board values sync settings with default values when loading a game on a board with them
This commit is contained in:
parent
76f285a58a
commit
4f159b4c20
|
@ -729,6 +729,22 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
||||||
|
|
||||||
public static class AutoMapperProps
|
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)
|
public static void Apply(NES.INESBoard board)
|
||||||
{
|
{
|
||||||
var fields = board.GetType().GetFields();
|
var fields = board.GetType().GetFields();
|
||||||
|
|
|
@ -426,6 +426,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
||||||
nsfboard.WRAM = new byte[cart.wram_size * 1024];
|
nsfboard.WRAM = new byte[cart.wram_size * 1024];
|
||||||
Board = nsfboard;
|
Board = nsfboard;
|
||||||
Board.PostConfigure();
|
Board.PostConfigure();
|
||||||
|
AutoMapperProps.Populate(Board, SyncSettings);
|
||||||
|
|
||||||
Console.WriteLine("Using NTSC display type for NSF for now");
|
Console.WriteLine("Using NTSC display type for NSF for now");
|
||||||
_display_type = Common.DisplayType.NTSC;
|
_display_type = Common.DisplayType.NTSC;
|
||||||
|
@ -463,6 +464,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
||||||
Board.VRAM = new byte[cart.vram_size * 1024];
|
Board.VRAM = new byte[cart.vram_size * 1024];
|
||||||
|
|
||||||
Board.PostConfigure();
|
Board.PostConfigure();
|
||||||
|
AutoMapperProps.Populate(Board, SyncSettings);
|
||||||
|
|
||||||
Console.WriteLine("Using NTSC display type for FDS disk image");
|
Console.WriteLine("Using NTSC display type for FDS disk image");
|
||||||
_display_type = Common.DisplayType.NTSC;
|
_display_type = Common.DisplayType.NTSC;
|
||||||
|
@ -709,6 +711,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
||||||
Board.VRAM = new byte[cart.vram_size * 1024];
|
Board.VRAM = new byte[cart.vram_size * 1024];
|
||||||
|
|
||||||
Board.PostConfigure();
|
Board.PostConfigure();
|
||||||
|
AutoMapperProps.Populate(Board, SyncSettings);
|
||||||
|
|
||||||
// set up display type
|
// set up display type
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue