From 720a2dce028e7de77c81df84ce8d04fff318e5dc Mon Sep 17 00:00:00 2001 From: adelikat Date: Thu, 19 Mar 2020 20:21:29 -0500 Subject: [PATCH] NesHawk - move NesBoardImpl attributes to their own file --- .../Consoles/Nintendo/NES/Boards/AxROM.cs | 2 +- .../Consoles/Nintendo/NES/Boards/CNROM.cs | 2 +- .../Consoles/Nintendo/NES/Boards/ExROM.cs | 2 +- .../Consoles/Nintendo/NES/Boards/GxROM.cs | 2 +- .../Consoles/Nintendo/NES/Boards/IC_74x377.cs | 2 +- .../NES/Boards/InesBoardImplAttribute.cs | 22 +++++++++++++++++++ .../Nintendo/NES/Boards/MMC3_family/TxROM.cs | 2 +- .../Consoles/Nintendo/NES/Boards/Mapper116.cs | 2 +- .../Consoles/Nintendo/NES/Boards/Mapper221.cs | 8 +++++++ .../Consoles/Nintendo/NES/Boards/NROM.cs | 2 +- .../Consoles/Nintendo/NES/Boards/NSFBoard.cs | 2 +- .../Nintendo/NES/Boards/Namcot129_163.cs | 2 +- .../Nintendo/NES/Boards/Namcot175_340.cs | 2 +- .../NES/Boards/Namcot1xx/Mapper206.cs | 2 +- .../Nintendo/NES/Boards/NesBoardBase.cs | 2 +- .../Consoles/Nintendo/NES/Boards/SxROM.cs | 2 +- .../Consoles/Nintendo/NES/Boards/UxROM.cs | 2 +- .../Consoles/Nintendo/NES/Boards/VS_M99.cs | 2 +- .../Consoles/Nintendo/NES/FDS/FDS.cs | 2 +- .../Consoles/Nintendo/NES/NES.BoardSystem.cs | 15 +++---------- 20 files changed, 50 insertions(+), 29 deletions(-) create mode 100644 BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/InesBoardImplAttribute.cs diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/AxROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/AxROM.cs index c1ba34a1af..5ed0c27c34 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/AxROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/AxROM.cs @@ -4,7 +4,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { //generally mapper7 - [NES.INESBoardImplPriority] + [NesBoardImplPriority] public sealed class AxROM : NesBoardBase { //configuration diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CNROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CNROM.cs index e64fdffd79..5ad44dc794 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CNROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/CNROM.cs @@ -11,7 +11,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES //Bump 'n' Jump //Cybernoid - [NES.INESBoardImplPriority] + [NesBoardImplPriority] public sealed class CNROM : NesBoardBase { //configuration diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/ExROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/ExROM.cs index 9bd5a3ff2b..601b9cb3ec 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/ExROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/ExROM.cs @@ -17,7 +17,7 @@ using BizHawk.Emulation.Cores.Components; //FUTURE - we may need to split this into a separate MMC5 class. but for now it is just a pain. namespace BizHawk.Emulation.Cores.Nintendo.NES { - [NES.INESBoardImplPriorityAttribute] + [NesBoardImplPriority] public sealed class ExROM : NesBoardBase { private int prg_bank_mask_8k, chr_bank_mask_1k; //board setup (to be isolated from mmc5 code later, when we need the separate mmc5 class) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/GxROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/GxROM.cs index f7b84bfd3a..d2d7511734 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/GxROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/GxROM.cs @@ -13,7 +13,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES //TODO - bus conflicts - [NES.INESBoardImplPriority] + [NesBoardImplPriority] public sealed class GxROM : NesBoardBase { //configuraton diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IC_74x377.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IC_74x377.cs index c28ad54dd0..d1522e9218 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IC_74x377.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/IC_74x377.cs @@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES //Crystal Mines //Metal Fighter - [NES.INESBoardImplPriority] + [NesBoardImplPriority] public sealed class IC_74x377 : NesBoardBase { //configuration diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/InesBoardImplAttribute.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/InesBoardImplAttribute.cs new file mode 100644 index 0000000000..d016d96d64 --- /dev/null +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/InesBoardImplAttribute.cs @@ -0,0 +1,22 @@ +using System; + +namespace BizHawk.Emulation.Cores.Nintendo.NES +{ + // this will be used to track classes that implement boards + [AttributeUsage(AttributeTargets.Class)] + public sealed class NesBoardImplAttribute : Attribute + { + } + + // this tracks derived boards that shouldn't be used by the implementation scanner + [AttributeUsage(AttributeTargets.Class)] + public sealed class NesBoardImplCancelAttribute : Attribute + { + } + + // flags it as being priority, i.e. in the top of the list + [AttributeUsage(AttributeTargets.Class)] + public sealed class NesBoardImplPriorityAttribute : Attribute + { + } +} diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TxROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TxROM.cs index 3559bb7285..c61460d75a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TxROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/MMC3_family/TxROM.cs @@ -5,7 +5,7 @@ using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.NES { - [NES.INESBoardImplPriority] + [NesBoardImplPriority] public sealed class TxROM : MMC3Board_Base { public override void WritePrg(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper116.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper116.cs index 1bcb088e19..6934dc2540 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper116.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper116.cs @@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { public sealed class Mapper116 : NesBoardBase { - [NES.INESBoardImplCancel] + [NesBoardImplCancel] class MMC3_CustomBoard : MMC3Board_Base { public override void WritePrg(int addr, byte value) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper221.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper221.cs index 0520fcf20a..93e063898b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper221.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Mapper221.cs @@ -27,6 +27,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES base.SyncState(ser); } + public override void NesSoftReset() + { + for (int i = 0; i < regs.Length; i++) + { + regs[i] = 0; + } + } + public override void WritePrg(int addr, byte value) { if (addr < 0x4000) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NROM.cs index e1b62e7ed5..91974fafcb 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NROM.cs @@ -1,6 +1,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { - [NES.INESBoardImplPriority] + [NesBoardImplPriority] public sealed class NROM : NesBoardBase { //configuration diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NSFBoard.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NSFBoard.cs index a7a852685d..43f34d03f6 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NSFBoard.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NSFBoard.cs @@ -17,7 +17,7 @@ using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.NES { - [NES.INESBoardImplCancel] + [NesBoardImplCancel] public sealed class NSFBoard : NesBoardBase { //------------------------------ diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot129_163.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot129_163.cs index 82a8de7a71..6f674b7170 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot129_163.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot129_163.cs @@ -13,7 +13,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES // what we have here should work for everything that's actually a 129 or 163, // and some of the 175/340 (mapper 210) - [NES.INESBoardImplPriority] + [NesBoardImplPriority] public sealed class Namcot129_163 : NesBoardBase { //configuration diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot175_340.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot175_340.cs index b15cc1016e..5427216057 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot175_340.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot175_340.cs @@ -3,7 +3,7 @@ using BizHawk.Common.NumberExtensions; namespace BizHawk.Emulation.Cores.Nintendo.NES { - [NES.INESBoardImplPriority] + [NesBoardImplPriority] public class Namcot175_340 : NesBoardBase { /* diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper206.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper206.cs index b5e2d2f3bc..f77b797012 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper206.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/Namcot1xx/Mapper206.cs @@ -1,7 +1,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { //various japanese Namcot108 boards plus DEROM - [NES.INESBoardImplPriority] + [NesBoardImplPriority] public sealed class Mapper206 : Namcot108Board_Base { public override bool Configure(NES.EDetectionOrigin origin) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NesBoardBase.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NesBoardBase.cs index 5f3f80e7d7..be96f09227 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NesBoardBase.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/NesBoardBase.cs @@ -4,7 +4,7 @@ using BizHawk.Common; namespace BizHawk.Emulation.Cores.Nintendo.NES { - [NES.INESBoardImpl] + [NesBoardImpl] public abstract class NesBoardBase : INesBoard { /// diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SxROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SxROM.cs index cb79a81aa0..599133d684 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SxROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/SxROM.cs @@ -235,7 +235,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } } - [NES.INESBoardImplPriority] + [NesBoardImplPriority] public class SxROM : NesBoardBase { //configuration diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UxROM.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UxROM.cs index 8937757077..36f04294bc 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UxROM.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/UxROM.cs @@ -15,7 +15,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES // why are there no bus conflicts in here??????? - [NES.INESBoardImplPriority] + [NesBoardImplPriority] public sealed class UxROM : NesBoardBase { //configuration diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VS_M99.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VS_M99.cs index b40eaa5f02..299cda6198 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VS_M99.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/Boards/VS_M99.cs @@ -4,7 +4,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { //VS System Mapper 99 - [NES.INESBoardImplPriority] + [NesBoardImplPriority] public sealed class MAPPER99 : NesBoardBase { //configuration diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/FDS.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/FDS.cs index cdabe7f840..5a9c33e280 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/FDS.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/FDS.cs @@ -14,7 +14,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES * http://wiki.nesdev.com/w/index.php/Family_Computer_Disk_System - these two documents * http://nesdev.com/diskspec.txt - not useless */ - [NES.INESBoardImplCancel] + [NesBoardImplCancel] public class FDS : NesBoardBase { #region configuration diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.BoardSystem.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.BoardSystem.cs index a77dcc190c..63cec13829 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.BoardSystem.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.BoardSystem.cs @@ -12,16 +12,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES { partial class NES { - //this will be used to track classes that implement boards - [AttributeUsage(AttributeTargets.Class)] - public sealed class INESBoardImplAttribute : Attribute { } - //this tracks derived boards that shouldn't be used by the implementation scanner - [AttributeUsage(AttributeTargets.Class)] - public sealed class INESBoardImplCancelAttribute : Attribute { } static List INESBoardImplementors = new List(); - //flags it as being priority, i.e. in the top of the list - [AttributeUsage(AttributeTargets.Class)] - public sealed class INESBoardImplPriorityAttribute : Attribute { } static INesBoard CreateBoardInstance(Type boardType) { @@ -101,12 +92,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES //scan types in this assembly to find ones that implement boards to add them to the list foreach (Type type in typeof(NES).Assembly.GetTypes()) { - var attrs = type.GetCustomAttributes(typeof(INESBoardImplAttribute), true); + var attrs = type.GetCustomAttributes(typeof(NesBoardImplAttribute), true); if (attrs.Length == 0) continue; if (type.IsAbstract) continue; - var cancelAttrs = type.GetCustomAttributes(typeof(INESBoardImplCancelAttribute), true); + var cancelAttrs = type.GetCustomAttributes(typeof(NesBoardImplCancelAttribute), true); if (cancelAttrs.Length != 0) continue; - var priorityAttrs = type.GetCustomAttributes(typeof(INESBoardImplPriorityAttribute), true); + var priorityAttrs = type.GetCustomAttributes(typeof(NesBoardImplPriorityAttribute), true); if (priorityAttrs.Length != 0) highPriority.Add(type); else normalPriority.Add(type);