NesHawk - move NesBoardImpl attributes to their own file

This commit is contained in:
adelikat 2020-03-19 20:21:29 -05:00
parent 0d4dd3855b
commit 720a2dce02
20 changed files with 50 additions and 29 deletions

View File

@ -4,7 +4,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
//generally mapper7
[NES.INESBoardImplPriority]
[NesBoardImplPriority]
public sealed class AxROM : NesBoardBase
{
//configuration

View File

@ -11,7 +11,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
//Bump 'n' Jump
//Cybernoid
[NES.INESBoardImplPriority]
[NesBoardImplPriority]
public sealed class CNROM : NesBoardBase
{
//configuration

View File

@ -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)

View File

@ -13,7 +13,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
//TODO - bus conflicts
[NES.INESBoardImplPriority]
[NesBoardImplPriority]
public sealed class GxROM : NesBoardBase
{
//configuraton

View File

@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
//Crystal Mines
//Metal Fighter
[NES.INESBoardImplPriority]
[NesBoardImplPriority]
public sealed class IC_74x377 : NesBoardBase
{
//configuration

View File

@ -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
{
}
}

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -1,6 +1,6 @@
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
[NES.INESBoardImplPriority]
[NesBoardImplPriority]
public sealed class NROM : NesBoardBase
{
//configuration

View File

@ -17,7 +17,7 @@ using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
[NES.INESBoardImplCancel]
[NesBoardImplCancel]
public sealed class NSFBoard : NesBoardBase
{
//------------------------------

View File

@ -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

View File

@ -3,7 +3,7 @@ using BizHawk.Common.NumberExtensions;
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
[NES.INESBoardImplPriority]
[NesBoardImplPriority]
public class Namcot175_340 : NesBoardBase
{
/*

View File

@ -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)

View File

@ -4,7 +4,7 @@ using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Nintendo.NES
{
[NES.INESBoardImpl]
[NesBoardImpl]
public abstract class NesBoardBase : INesBoard
{
/// <summary>

View File

@ -235,7 +235,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
}
[NES.INESBoardImplPriority]
[NesBoardImplPriority]
public class SxROM : NesBoardBase
{
//configuration

View File

@ -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

View File

@ -4,7 +4,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{
//VS System Mapper 99
[NES.INESBoardImplPriority]
[NesBoardImplPriority]
public sealed class MAPPER99 : NesBoardBase
{
//configuration

View File

@ -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

View File

@ -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<Type> INESBoardImplementors = new List<Type>();
//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);