using System.Collections.Generic;
using BizHawk.Client.ApiHawk;
namespace BizHawk.Client.Common
{
///
/// This class holds logic for System information.
/// That means specifications about a system that BizHawk emulates
///
public sealed class SystemInfo
{
#region Fields
private const JoypadButton UpDownLeftRight = JoypadButton.Up | JoypadButton.Down | JoypadButton.Left | JoypadButton.Right;
private const JoypadButton StandardButtons = JoypadButton.A | JoypadButton.B | JoypadButton.Start | JoypadButton.Select | UpDownLeftRight;
private static readonly List _allSystemInfos = new List();
#endregion
#region cTor(s)
///
/// Initializes a new instance of the class
///
/// A that specify how the system name is displayed
/// A that specify what core is used
/// Maximum controller allowed by this system
/// Which buttons are available (i.e. are actually on the controller) for this system
private SystemInfo(string displayName, CoreSystem system, int maxControllers, JoypadButton availableButtons = 0)
{
DisplayName = displayName;
System = system;
MaxControllers = maxControllers;
AvailableButtons = availableButtons;
_allSystemInfos.Add(this);
}
#endregion
#region Methods
#region Get SystemInfo
///
/// Gets the instance for Apple II
///
public static SystemInfo Libretro { get; } = new SystemInfo("Libretro", CoreSystem.Libretro, 1);
///
/// Gets the instance for Apple II
///
public static SystemInfo AppleII { get; } = new SystemInfo("Apple II", CoreSystem.AppleII, 1);
///
/// Gets the instance for Atari 2600
///
public static SystemInfo Atari2600 { get; } = new SystemInfo("Atari 2600", CoreSystem.Atari2600, 1);
///
/// Gets the instance for Atari 7800
///
public static SystemInfo Atari7800 { get; } = new SystemInfo("Atari 7800", CoreSystem.Atari7800, 1);
///
/// Gets the instance for Commodore 64
///
public static SystemInfo C64 { get; } = new SystemInfo("Commodore 64", CoreSystem.Commodore64, 1);
///
/// Gets the instance for Coleco Vision
///
public static SystemInfo Coleco { get; } = new SystemInfo("ColecoVision", CoreSystem.ColecoVision, 1);
///
/// Gets the instance for Dual Gameboy
///
public static SystemInfo DualGB { get; } = new SystemInfo("Game Boy Link", CoreSystem.DualGameBoy, 2, StandardButtons);
///
/// Gets the instance for Gameboy
///
public static SystemInfo GB { get; } = new SystemInfo("GB", CoreSystem.GameBoy, 1, StandardButtons);
///
/// Gets the instance for Gameboy Advance
///
public static SystemInfo GBA { get; } = new SystemInfo("Gameboy Advance", CoreSystem.GameBoyAdvance, 1, StandardButtons | JoypadButton.L | JoypadButton.R);
///
/// Gets the instance for Gameboy Color
///
public static SystemInfo GBC { get; } = new SystemInfo("Gameboy Color", CoreSystem.GameBoy, 1, StandardButtons);
///
/// Gets the instance for Genesis
///
public static SystemInfo Genesis { get; } = new SystemInfo("Genesis", CoreSystem.Genesis, 2, UpDownLeftRight | JoypadButton.A | JoypadButton.B | JoypadButton.C | JoypadButton.X | JoypadButton.Y | JoypadButton.Z);
///
/// Gets the instance for Game Gear
///
public static SystemInfo GG { get; } = new SystemInfo("Game Gear", CoreSystem.MasterSystem, 1, UpDownLeftRight | JoypadButton.B1 | JoypadButton.B2);
///
/// Gets the instance for Intellivision
///
public static SystemInfo Intellivision { get; } = new SystemInfo("Intellivision", CoreSystem.Intellivision, 2);
///
/// Gets the instance for Lynx
///
public static SystemInfo Lynx { get; } = new SystemInfo("Lynx", CoreSystem.Lynx, 1);
///
/// Gets the instance for NES
///
public static SystemInfo Nes { get; } = new SystemInfo("NES", CoreSystem.NES, 2, StandardButtons);
///
/// Gets the instance for Nintendo 64
///
public static SystemInfo N64 { get; } = new SystemInfo("Nintendo 64", CoreSystem.Nintendo64, 4, StandardButtons ^ JoypadButton.Select | JoypadButton.Z | JoypadButton.CUp | JoypadButton.CDown | JoypadButton.CLeft | JoypadButton.CRight | JoypadButton.AnalogStick | JoypadButton.L | JoypadButton.R);
///
/// Gets the instance for Null (i.e. nothing is emulated) emulator
///
public static SystemInfo Null { get; } = new SystemInfo("", CoreSystem.Null, 0);
///
/// Gets the instance for PCEngine (TurboGrafx-16)
///
public static SystemInfo PCE { get; } = new SystemInfo("TurboGrafx-16", CoreSystem.PCEngine, 1);
///
/// Gets the instance for PCEngine (TurboGrafx-16) + CD
///
public static SystemInfo PCECD { get; } = new SystemInfo("TurboGrafx - 16(CD)", CoreSystem.PCEngine, 1);
///
/// Gets the instance for PlayStation
///
public static SystemInfo PSX { get; } = new SystemInfo("PlayStation", CoreSystem.Playstation, 2);
///
/// Gets the instance for Sega Saturn
///
public static SystemInfo Saturn { get; } = new SystemInfo("Saturn", CoreSystem.Saturn, 2, UpDownLeftRight | JoypadButton.A | JoypadButton.B | JoypadButton.C | JoypadButton.X | JoypadButton.Y | JoypadButton.Z);
///
/// Gets the instance for SG-1000 (Sega Game 1000)
///
public static SystemInfo SG { get; } = new SystemInfo("SG-1000", CoreSystem.MasterSystem, 1);
///
/// Gets the instance for PCEngine (Supergraph FX)
///
public static SystemInfo SGX { get; } = new SystemInfo("SuperGrafx", CoreSystem.PCEngine, 1);
///
/// Gets the instance for Sega Master System
///
public static SystemInfo SMS { get; } = new SystemInfo("Sega Master System", CoreSystem.MasterSystem, 2, UpDownLeftRight | JoypadButton.B1 | JoypadButton.B2);
///
/// Gets the instance for SNES
///
public static SystemInfo SNES { get; } = new SystemInfo("SNES", CoreSystem.SNES, 8, StandardButtons | JoypadButton.X | JoypadButton.Y | JoypadButton.L | JoypadButton.R);
///
/// Gets the instance for TI-83
///
public static SystemInfo TI83 { get; } = new SystemInfo("TI - 83", CoreSystem.TI83, 1);
///
/// Gets the instance for Wonderswan
///
public static SystemInfo WonderSwan { get; } = new SystemInfo("WonderSwan", CoreSystem.WonderSwan, 1);
///
/// Gets the instance for Virtual Boy
///
public static SystemInfo VirtualBoy { get; } = new SystemInfo("Virtual Boy", CoreSystem.VirtualBoy, 1);
///
/// Gets the instance for TI-83
///
public static SystemInfo NeoGeoPocket { get; } = new SystemInfo("Neo-Geo Pocket", CoreSystem.NeoGeoPocket, 1);
///
/// Gets the instance for ZXSpectrum
///
public static SystemInfo ZXSpectrum { get; } = new SystemInfo("ZX Spectrum", CoreSystem.ZXSpectrum, 2);
///
/// Gets the instance for AmstradCPC
///
public static SystemInfo AmstradCPC { get; } = new SystemInfo("Amstrad CPC", CoreSystem.AmstradCPC, 2);
///
/// Gets the instance for AmstradCPC
///
public static SystemInfo GGL { get; } = new SystemInfo("Game Gear Linked", CoreSystem.GGL, 2);
#endregion Get SystemInfo
///
/// Get a by its
///
/// you're looking for
///
public static SystemInfo FindByCoreSystem(CoreSystem system)
{
return _allSystemInfos.Find(s => s.System == system);
}
///
/// Determine if this is equal to specified
///
/// to compare to
/// True if object is equal to this instance; otherwise, false
public override bool Equals(object obj)
{
if (obj is SystemInfo)
{
return this == (SystemInfo)obj;
}
return base.Equals(obj);
}
///
/// Gets the haschode for current instance
///
/// This instance hashcode
public override int GetHashCode()
{
return base.GetHashCode();
}
///
/// Returns a representation of current
/// In fact, return the same as DisplayName property
///
public override string ToString()
{
return DisplayName;
}
///
/// Determine if two are equals.
/// As it is all static instance, it just compare their reference
///
/// First
/// Second
/// True if both system are equals; otherwise, false
public static bool operator ==(SystemInfo system1, SystemInfo system2)
{
return ReferenceEquals(system1, system2);
}
///
/// Determine if two are different.
/// As it is all static instance, it just compare their reference
///
/// First
/// Second
/// True if both system are different; otherwise, false
public static bool operator !=(SystemInfo system1, SystemInfo system2)
{
return !(system1 == system2);
}
#endregion
#region Properties
///
/// Gets available for this system
///
public JoypadButton AvailableButtons { get; }
///
/// Gets the system name as
///
public string DisplayName { get; }
///
/// Gets the maximum amount of controller allowed for this system
///
public int MaxControllers { get; }
///
/// Gets core used for this system as enum
///
public CoreSystem System { get; }
#endregion
}
}