use constants for core string names and simplify core core name getting logic
This commit is contained in:
parent
0d2daa24d5
commit
b736d48911
|
@ -2,6 +2,7 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
using BizHawk.Emulation.Common;
|
using BizHawk.Emulation.Common;
|
||||||
|
using BizHawk.Emulation.Cores;
|
||||||
using BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES;
|
using BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES;
|
||||||
using BizHawk.Emulation.Cores.Nintendo.Gameboy;
|
using BizHawk.Emulation.Cores.Nintendo.Gameboy;
|
||||||
using BizHawk.Emulation.Cores.Nintendo.NES;
|
using BizHawk.Emulation.Cores.Nintendo.NES;
|
||||||
|
@ -252,69 +253,59 @@ namespace BizHawk.Client.Common
|
||||||
// Don't set it to a movie instance of the adapter or you will lose the definition!
|
// Don't set it to a movie instance of the adapter or you will lose the definition!
|
||||||
Global.InputManager.RewireInputChain();
|
Global.InputManager.RewireInputChain();
|
||||||
|
|
||||||
if (!record && emulator.SystemId == "NES") // For NES we need special logic since the movie will drive which core to load
|
if (!record)
|
||||||
{
|
{
|
||||||
var quicknesName = typeof(QuickNES).CoreName();
|
switch (emulator.SystemId)
|
||||||
var neshawkName = typeof(NES).CoreName();
|
|
||||||
|
|
||||||
// If either is specified use that, else use whatever is currently set
|
|
||||||
if (movie.Core == quicknesName)
|
|
||||||
{
|
{
|
||||||
PreviousNesInQuickNES = Global.Config.NesInQuickNes;
|
case "NES":
|
||||||
Global.Config.NesInQuickNes = true;
|
if (movie.Core == CoreNames.QuickNes)
|
||||||
}
|
{
|
||||||
else if (movie.Core == neshawkName)
|
PreviousNesInQuickNES = Global.Config.NesInQuickNes;
|
||||||
{
|
Global.Config.NesInQuickNes = true;
|
||||||
PreviousNesInQuickNES = Global.Config.NesInQuickNes;
|
}
|
||||||
Global.Config.NesInQuickNes = false;
|
else if (movie.Core == CoreNames.NesHawk)
|
||||||
}
|
{
|
||||||
}
|
PreviousNesInQuickNES = Global.Config.NesInQuickNes;
|
||||||
else if (!record && emulator.SystemId == "SNES") // ditto with snes9x vs bsnes
|
Global.Config.NesInQuickNes = false;
|
||||||
{
|
}
|
||||||
var snes9XName = typeof(Snes9x).CoreName();
|
break;
|
||||||
var bsnesName = typeof(LibsnesCore).CoreName();
|
case "SNES":
|
||||||
|
if (movie.Core == CoreNames.Snes9X)
|
||||||
if (movie.Core == snes9XName)
|
{
|
||||||
{
|
PreviousSnesInSnes9x = Global.Config.SnesInSnes9x;
|
||||||
PreviousSnesInSnes9x = Global.Config.SnesInSnes9x;
|
Global.Config.SnesInSnes9x = true;
|
||||||
Global.Config.SnesInSnes9x = true;
|
}
|
||||||
}
|
else if (movie.Core == CoreNames.Bsnes)
|
||||||
else if (movie.Core == bsnesName)
|
{
|
||||||
{
|
PreviousSnesInSnes9x = Global.Config.SnesInSnes9x;
|
||||||
PreviousSnesInSnes9x = Global.Config.SnesInSnes9x;
|
Global.Config.SnesInSnes9x = false;
|
||||||
Global.Config.SnesInSnes9x = false;
|
}
|
||||||
}
|
break;
|
||||||
}
|
case "GBA":
|
||||||
else if (!record && emulator.SystemId == "GBA") // ditto with GBA, we should probably architect this at some point, this isn't sustainable
|
if (movie.Core == CoreNames.Mgba)
|
||||||
{
|
{
|
||||||
var mGBAName = typeof(MGBAHawk).CoreName();
|
PreviousGbaUsemGba = Global.Config.GbaUsemGba;
|
||||||
var vbaNextName = typeof(VBANext).CoreName();
|
Global.Config.GbaUsemGba = true;
|
||||||
|
}
|
||||||
if (movie.Core == mGBAName)
|
else if (movie.Core == CoreNames.VbaNext)
|
||||||
{
|
{
|
||||||
PreviousGbaUsemGba = Global.Config.GbaUsemGba;
|
PreviousGbaUsemGba = Global.Config.GbaUsemGba;
|
||||||
Global.Config.GbaUsemGba = true;
|
Global.Config.GbaUsemGba = false;
|
||||||
}
|
}
|
||||||
else if (movie.Core == vbaNextName)
|
break;
|
||||||
{
|
case "GB":
|
||||||
PreviousGbaUsemGba = Global.Config.GbaUsemGba;
|
case "GBC":
|
||||||
Global.Config.GbaUsemGba = false;
|
if (movie.Core == CoreNames.GbHawk)
|
||||||
}
|
{
|
||||||
}
|
PreviousGbUseGbHawk = Global.Config.GbUseGbHawk;
|
||||||
else if (!record && (emulator.SystemId == "GB" || emulator.SystemId == "GBC"))
|
Global.Config.GbUseGbHawk = true;
|
||||||
{
|
}
|
||||||
var gbHawkName = typeof(GBHawk).CoreName();
|
else if (movie.Core == CoreNames.Gambatte)
|
||||||
var gambatteName = typeof(Gameboy).CoreName();
|
{
|
||||||
|
PreviousGbUseGbHawk = Global.Config.GbUseGbHawk;
|
||||||
if (movie.Core == gbHawkName)
|
Global.Config.GbUseGbHawk = false;
|
||||||
{
|
}
|
||||||
PreviousGbUseGbHawk = Global.Config.GbUseGbHawk;
|
break;
|
||||||
Global.Config.GbUseGbHawk = true;
|
|
||||||
}
|
|
||||||
else if (movie.Core == gambatteName)
|
|
||||||
{
|
|
||||||
PreviousGbUseGbHawk = Global.Config.GbUseGbHawk;
|
|
||||||
Global.Config.GbUseGbHawk = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -297,18 +297,6 @@ namespace BizHawk.Emulation.Common
|
||||||
return core.VsyncNumerator() / (double)core.VsyncDenominator();
|
return core.VsyncNumerator() / (double)core.VsyncDenominator();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: a better place for these
|
|
||||||
public static string CoreName(this Type type)
|
|
||||||
{
|
|
||||||
if (type == null)
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
var attr = (CoreAttribute)Attribute.GetCustomAttribute(type, typeof(CoreAttribute));
|
|
||||||
return attr?.CoreName ?? "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsImplemented(this MethodInfo info)
|
public static bool IsImplemented(this MethodInfo info)
|
||||||
{
|
{
|
||||||
return !info.GetCustomAttributes(false).Any(a => a is FeatureNotImplementedAttribute);
|
return !info.GetCustomAttributes(false).Any(a => a is FeatureNotImplementedAttribute);
|
||||||
|
|
|
@ -4,7 +4,7 @@ using BizHawk.Emulation.Common;
|
||||||
|
|
||||||
namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
||||||
{
|
{
|
||||||
[Core("mGBA", "endrift", true, true, "0.8", "https://mgba.io/", false)]
|
[Core(CoreNames.Mgba, "endrift", true, true, "0.8", "https://mgba.io/", false)]
|
||||||
[ServiceNotApplicable(new[] { typeof(IDriveLight), typeof(IRegionable) })]
|
[ServiceNotApplicable(new[] { typeof(IDriveLight), typeof(IRegionable) })]
|
||||||
public partial class MGBAHawk : IEmulator, IVideoProvider, ISoundProvider, IGBAGPUViewable,
|
public partial class MGBAHawk : IEmulator, IVideoProvider, ISoundProvider, IGBAGPUViewable,
|
||||||
ISaveRam, IStatable, IInputPollable, ISettable<MGBAHawk.Settings, MGBAHawk.SyncSettings>,
|
ISaveRam, IStatable, IInputPollable, ISettable<MGBAHawk.Settings, MGBAHawk.SyncSettings>,
|
||||||
|
|
|
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
||||||
namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
|
||||||
{
|
{
|
||||||
[Core(
|
[Core(
|
||||||
"GBHawk",
|
CoreNames.GbHawk,
|
||||||
"",
|
"",
|
||||||
isPorted: false,
|
isPorted: false,
|
||||||
isReleased: true)]
|
isReleased: true)]
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
||||||
/// a gameboy/gameboy color emulator wrapped around native C++ libgambatte
|
/// a gameboy/gameboy color emulator wrapped around native C++ libgambatte
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Core(
|
[Core(
|
||||||
"Gambatte",
|
CoreNames.Gambatte,
|
||||||
"",
|
"",
|
||||||
isPorted: true,
|
isPorted: true,
|
||||||
isReleased: true,
|
isReleased: true,
|
||||||
|
|
|
@ -10,7 +10,7 @@ using BizHawk.Emulation.Common;
|
||||||
namespace BizHawk.Emulation.Cores.Nintendo.NES
|
namespace BizHawk.Emulation.Cores.Nintendo.NES
|
||||||
{
|
{
|
||||||
[Core(
|
[Core(
|
||||||
"NesHawk",
|
CoreNames.NesHawk,
|
||||||
"zeromus, natt, alyosha, adelikat",
|
"zeromus, natt, alyosha, adelikat",
|
||||||
isPorted: false,
|
isPorted: false,
|
||||||
isReleased: true)]
|
isReleased: true)]
|
||||||
|
|
|
@ -14,7 +14,7 @@ using BizHawk.Common.BufferExtensions;
|
||||||
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
|
||||||
{
|
{
|
||||||
[Core(
|
[Core(
|
||||||
"QuickNes",
|
CoreNames.QuickNes,
|
||||||
"",
|
"",
|
||||||
isPorted: true,
|
isPorted: true,
|
||||||
isReleased: true,
|
isReleased: true,
|
||||||
|
|
|
@ -18,7 +18,7 @@ using BizHawk.Emulation.Cores.Components.W65816;
|
||||||
namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
||||||
{
|
{
|
||||||
[Core(
|
[Core(
|
||||||
"BSNES",
|
CoreNames.Bsnes,
|
||||||
"byuu",
|
"byuu",
|
||||||
isPorted: true,
|
isPorted: true,
|
||||||
isReleased: true,
|
isReleased: true,
|
||||||
|
|
|
@ -9,7 +9,7 @@ using System.Linq;
|
||||||
|
|
||||||
namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
|
namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
|
||||||
{
|
{
|
||||||
[Core("Snes9x", "", true, true,
|
[Core(CoreNames.Snes9X, "", true, true,
|
||||||
"5e0319ab3ef9611250efb18255186d0dc0d7e125", "https://github.com/snes9xgit/snes9x", false)]
|
"5e0319ab3ef9611250efb18255186d0dc0d7e125", "https://github.com/snes9xgit/snes9x", false)]
|
||||||
[ServiceNotApplicable(new[] { typeof(IDriveLight) })]
|
[ServiceNotApplicable(new[] { typeof(IDriveLight) })]
|
||||||
public class Snes9x : WaterboxCore,
|
public class Snes9x : WaterboxCore,
|
||||||
|
|
|
@ -4,7 +4,7 @@ using BizHawk.Emulation.Cores.Nintendo.NES;
|
||||||
namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk
|
namespace BizHawk.Emulation.Cores.Nintendo.SubNESHawk
|
||||||
{
|
{
|
||||||
[Core(
|
[Core(
|
||||||
"SubNESHawk",
|
CoreNames.SubNesHawk,
|
||||||
"",
|
"",
|
||||||
isPorted: false,
|
isPorted: false,
|
||||||
isReleased: true)]
|
isReleased: true)]
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
using BizHawk.Emulation.Common;
|
||||||
|
|
||||||
|
namespace BizHawk.Emulation.Cores
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Constant class for the names of cores, that should be used in every <see cref="CoreAttribute"/>
|
||||||
|
/// For now we are only including ones that can be picked as a core preference,
|
||||||
|
/// but all cores should be included ere
|
||||||
|
/// </summary>
|
||||||
|
public class CoreNames
|
||||||
|
{
|
||||||
|
public const string NesHawk = "NesHawk";
|
||||||
|
public const string SubNesHawk = "SubNESHawk";
|
||||||
|
public const string QuickNes = "QuickNes";
|
||||||
|
public const string Snes9X = "Snes9x";
|
||||||
|
public const string Bsnes = "BSNES";
|
||||||
|
public const string Mgba = "mGBA";
|
||||||
|
public const string VbaNext = "VBA-Next";
|
||||||
|
public const string GbHawk = "GBHawk";
|
||||||
|
public const string Gambatte = "Gambatte";
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue