Merge branch 'master' of github.com:alcexhim/UniversalEditor
This commit is contained in:
commit
9e7f6623c4
@ -51,6 +51,23 @@ namespace UniversalEditor
|
||||
public CustomOptionFieldChoice(string title) : this(title, title, false)
|
||||
{
|
||||
}
|
||||
public CustomOptionFieldChoice(object value)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
mvarTitle = value.ToString();
|
||||
}
|
||||
mvarValue = value;
|
||||
}
|
||||
public CustomOptionFieldChoice(object value, bool isDefault)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
mvarTitle = value.ToString();
|
||||
}
|
||||
mvarValue = value;
|
||||
mvarIsDefault = isDefault;
|
||||
}
|
||||
public CustomOptionFieldChoice(string title, object value) : this(title, value, false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -8,6 +8,9 @@ using UniversalEditor.ObjectModels.Executable;
|
||||
|
||||
namespace UniversalEditor.DataFormats.Executable.Nintendo.SNES
|
||||
{
|
||||
/// <summary>
|
||||
/// The Nintendo SNES SMC ROM data format.
|
||||
/// </summary>
|
||||
public class SMCDataFormat : DataFormat
|
||||
{
|
||||
private static DataFormatReference _dfr = null;
|
||||
@ -17,6 +20,211 @@ namespace UniversalEditor.DataFormats.Executable.Nintendo.SNES
|
||||
{
|
||||
_dfr = base.MakeReference();
|
||||
_dfr.Capabilities.Add(typeof(ExecutableObjectModel), DataFormatCapabilities.All);
|
||||
|
||||
_dfr.ExportOptions.Add(new CustomOptionChoice("Region", "&Region:", false, new CustomOptionFieldChoice[]
|
||||
{
|
||||
new CustomOptionFieldChoice(SMCRegions.Japan),
|
||||
new CustomOptionFieldChoice(SMCRegions.NorthAmerica),
|
||||
new CustomOptionFieldChoice(SMCRegions.Eurasia),
|
||||
new CustomOptionFieldChoice(SMCRegions.Sweden),
|
||||
new CustomOptionFieldChoice(SMCRegions.Finland),
|
||||
new CustomOptionFieldChoice(SMCRegions.Denmark),
|
||||
new CustomOptionFieldChoice(SMCRegions.France),
|
||||
new CustomOptionFieldChoice(SMCRegions.Holland),
|
||||
new CustomOptionFieldChoice(SMCRegions.Spain),
|
||||
new CustomOptionFieldChoice(SMCRegions.GermanyAustriaSwitzerland),
|
||||
new CustomOptionFieldChoice(SMCRegions.Italy),
|
||||
new CustomOptionFieldChoice(SMCRegions.HongKongAndChina),
|
||||
new CustomOptionFieldChoice(SMCRegions.Indonesia),
|
||||
new CustomOptionFieldChoice(SMCRegions.SouthKorea)
|
||||
}));
|
||||
|
||||
_dfr.ExportOptions.Add(new CustomOptionChoice("Licensee", "&Licensee:", false, new CustomOptionFieldChoice[]
|
||||
{
|
||||
new CustomOptionFieldChoice(SMCLicensees.None, true),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Nintendo0x01),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Ajinomoto),
|
||||
new CustomOptionFieldChoice(SMCLicensees.ImagineerZoom),
|
||||
new CustomOptionFieldChoice(SMCLicensees.ChrisGrayEnterprises),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Zamuse),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Falcom),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Capcom),
|
||||
new CustomOptionFieldChoice(SMCLicensees.HotB),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Jaleco0x0A),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Coconuts),
|
||||
new CustomOptionFieldChoice(SMCLicensees.RageSoftware),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Micronet),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Technos),
|
||||
new CustomOptionFieldChoice(SMCLicensees.MebioSoftware),
|
||||
new CustomOptionFieldChoice(SMCLicensees.SHOUEiSystem),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Starfish),
|
||||
new CustomOptionFieldChoice(SMCLicensees.GremlinGraphics0x12),
|
||||
new CustomOptionFieldChoice(SMCLicensees.ElectronicArts0x13),
|
||||
new CustomOptionFieldChoice(SMCLicensees.NCSMasaya),
|
||||
new CustomOptionFieldChoice(SMCLicensees.COBRATeam),
|
||||
new CustomOptionFieldChoice(SMCLicensees.HumanField),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Koei0x17),
|
||||
new CustomOptionFieldChoice(SMCLicensees.HudsonSoft),
|
||||
new CustomOptionFieldChoice(SMCLicensees.GameVillage),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Yanoman),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Tecmo),
|
||||
new CustomOptionFieldChoice(SMCLicensees.OpenSystem),
|
||||
new CustomOptionFieldChoice(SMCLicensees.VirginGames),
|
||||
new CustomOptionFieldChoice(SMCLicensees.KSS),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Sunsoft0x21),
|
||||
new CustomOptionFieldChoice(SMCLicensees.POW),
|
||||
new CustomOptionFieldChoice(SMCLicensees.MicroWorld),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Enix),
|
||||
new CustomOptionFieldChoice(SMCLicensees.LoricielElectroBrain),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Kemco0x28),
|
||||
new CustomOptionFieldChoice(SMCLicensees.SetaCoLtd),
|
||||
new CustomOptionFieldChoice(SMCLicensees.CultureBrain0x2A),
|
||||
new CustomOptionFieldChoice(SMCLicensees.IremJapan),
|
||||
new CustomOptionFieldChoice(SMCLicensees.PalSoft),
|
||||
new CustomOptionFieldChoice(SMCLicensees.VisitCoLtd),
|
||||
new CustomOptionFieldChoice(SMCLicensees.INTEC),
|
||||
new CustomOptionFieldChoice(SMCLicensees.SystemSacomCorp),
|
||||
new CustomOptionFieldChoice(SMCLicensees.ViacomNewMedia),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Carrozzeria),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Dynamic),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Nintendo0x33),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Magifact),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Hect),
|
||||
new CustomOptionFieldChoice(SMCLicensees.CapcomEurope),
|
||||
new CustomOptionFieldChoice(SMCLicensees.AccoladeEurope),
|
||||
new CustomOptionFieldChoice(SMCLicensees.ArcadeZone),
|
||||
new CustomOptionFieldChoice(SMCLicensees.EmpireSoftware),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Loriciel),
|
||||
new CustomOptionFieldChoice(SMCLicensees.GremlinGraphics0x3E),
|
||||
new CustomOptionFieldChoice(SMCLicensees.SeikaCorp),
|
||||
new CustomOptionFieldChoice(SMCLicensees.UBISoft),
|
||||
new CustomOptionFieldChoice(SMCLicensees.LifeFitnessExertainment),
|
||||
new CustomOptionFieldChoice(SMCLicensees.System3),
|
||||
new CustomOptionFieldChoice(SMCLicensees.SpectrumHolobyte),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Irem),
|
||||
new CustomOptionFieldChoice(SMCLicensees.RayaSystemsSculpturedSoftware),
|
||||
new CustomOptionFieldChoice(SMCLicensees.RenovationProducts),
|
||||
new CustomOptionFieldChoice(SMCLicensees.MalibuGamesBlackPearl),
|
||||
new CustomOptionFieldChoice(SMCLicensees.USGold),
|
||||
new CustomOptionFieldChoice(SMCLicensees.AbsoluteEntertainment),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Acclaim0x51),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Activision),
|
||||
new CustomOptionFieldChoice(SMCLicensees.AmericanSammy),
|
||||
new CustomOptionFieldChoice(SMCLicensees.GameTek),
|
||||
new CustomOptionFieldChoice(SMCLicensees.HiTechExpressions),
|
||||
new CustomOptionFieldChoice(SMCLicensees.LJNToys),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Mindscape),
|
||||
new CustomOptionFieldChoice(SMCLicensees.RomstarInc),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Tradewest),
|
||||
new CustomOptionFieldChoice(SMCLicensees.AmericanSoftworksCorp),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Titus),
|
||||
new CustomOptionFieldChoice(SMCLicensees.VirginInteractiveEntertainment),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Maxis),
|
||||
new CustomOptionFieldChoice(SMCLicensees.OriginFCIPonyCanyon),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Ocean),
|
||||
new CustomOptionFieldChoice(SMCLicensees.ElectronicArts0x69),
|
||||
new CustomOptionFieldChoice(SMCLicensees.LaserBeam),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Elite),
|
||||
new CustomOptionFieldChoice(SMCLicensees.ElectroBrain),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Infogrames),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Interplay),
|
||||
new CustomOptionFieldChoice(SMCLicensees.LucasArts),
|
||||
new CustomOptionFieldChoice(SMCLicensees.ParkerBrothers),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Konami0x74),
|
||||
new CustomOptionFieldChoice(SMCLicensees.STORM),
|
||||
new CustomOptionFieldChoice(SMCLicensees.THQSoftware),
|
||||
new CustomOptionFieldChoice(SMCLicensees.AccoladeInc),
|
||||
new CustomOptionFieldChoice(SMCLicensees.TriffixEntertainment),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Microprose),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Kemco0x7F),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Misawa),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Teichio),
|
||||
new CustomOptionFieldChoice(SMCLicensees.NamcoLtd0x82),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Lozc),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Koei0x84),
|
||||
new CustomOptionFieldChoice(SMCLicensees.TokumaShotenIntermedia),
|
||||
new CustomOptionFieldChoice(SMCLicensees.TsukudaOriginal),
|
||||
new CustomOptionFieldChoice(SMCLicensees.DATAMPolystar),
|
||||
new CustomOptionFieldChoice(SMCLicensees.BulletProofSoftware),
|
||||
new CustomOptionFieldChoice(SMCLicensees.VicTokai),
|
||||
new CustomOptionFieldChoice(SMCLicensees.CharacterSoft),
|
||||
new CustomOptionFieldChoice(SMCLicensees.IMax),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Takara0x90),
|
||||
new CustomOptionFieldChoice(SMCLicensees.CHUNSoft),
|
||||
new CustomOptionFieldChoice(SMCLicensees.VideoSystemCoLtd),
|
||||
new CustomOptionFieldChoice(SMCLicensees.BEC),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Varie),
|
||||
new CustomOptionFieldChoice(SMCLicensees.YonezawaSPalCorp),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Kaneco),
|
||||
new CustomOptionFieldChoice(SMCLicensees.PackInVideo),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Nichibutsu),
|
||||
new CustomOptionFieldChoice(SMCLicensees.TECMO),
|
||||
new CustomOptionFieldChoice(SMCLicensees.ImagineerCo),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Telenet),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Hori),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Konami0xA4),
|
||||
new CustomOptionFieldChoice(SMCLicensees.KAmusementLeasingCo),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Takara0xA7),
|
||||
new CustomOptionFieldChoice(SMCLicensees.TechnosJap),
|
||||
new CustomOptionFieldChoice(SMCLicensees.JVC),
|
||||
new CustomOptionFieldChoice(SMCLicensees.ToeiAnimation),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Toho),
|
||||
new CustomOptionFieldChoice(SMCLicensees.NamcoLtd0xAF),
|
||||
new CustomOptionFieldChoice(SMCLicensees.MediaRingsCorp),
|
||||
new CustomOptionFieldChoice(SMCLicensees.ASCIICoActivision),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Bandai),
|
||||
new CustomOptionFieldChoice(SMCLicensees.EnixAmerica),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Halken),
|
||||
new CustomOptionFieldChoice(SMCLicensees.CultureBrain0xBA),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Sunsoft0xBB),
|
||||
new CustomOptionFieldChoice(SMCLicensees.ToshibaEMI),
|
||||
new CustomOptionFieldChoice(SMCLicensees.SonyImagesoft),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Sammy),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Taito),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Kemco0xC2),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Square),
|
||||
new CustomOptionFieldChoice(SMCLicensees.TokumaSoft),
|
||||
new CustomOptionFieldChoice(SMCLicensees.DataEast),
|
||||
new CustomOptionFieldChoice(SMCLicensees.TonkinHouse),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Koei0xC8),
|
||||
new CustomOptionFieldChoice(SMCLicensees.KonamiUSA),
|
||||
new CustomOptionFieldChoice(SMCLicensees.NTVIC),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Meldac),
|
||||
new CustomOptionFieldChoice(SMCLicensees.PonyCanyon),
|
||||
new CustomOptionFieldChoice(SMCLicensees.SotsuAgencySunrise),
|
||||
new CustomOptionFieldChoice(SMCLicensees.DiscoTaito),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Sofel),
|
||||
new CustomOptionFieldChoice(SMCLicensees.QuestCorp),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Sigma),
|
||||
new CustomOptionFieldChoice(SMCLicensees.AskKodanshaCoLtd),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Naxat),
|
||||
new CustomOptionFieldChoice(SMCLicensees.CapcomCoLtd),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Banpresto),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Tomy),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Acclaim0xDB),
|
||||
new CustomOptionFieldChoice(SMCLicensees.NCS),
|
||||
new CustomOptionFieldChoice(SMCLicensees.HumanEntertainment),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Altron),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Jaleco0xE0),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Yutaka),
|
||||
new CustomOptionFieldChoice(SMCLicensees.TAndESoft),
|
||||
new CustomOptionFieldChoice(SMCLicensees.EPOCHCoLtd),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Athena),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Asmik),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Natsume),
|
||||
new CustomOptionFieldChoice(SMCLicensees.KingRecords),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Atlus),
|
||||
new CustomOptionFieldChoice(SMCLicensees.SonyMusicEntertainment),
|
||||
new CustomOptionFieldChoice(SMCLicensees.IGS),
|
||||
new CustomOptionFieldChoice(SMCLicensees.MotownSoftware),
|
||||
new CustomOptionFieldChoice(SMCLicensees.LeftFieldEntertainment),
|
||||
new CustomOptionFieldChoice(SMCLicensees.BeamSoftware),
|
||||
new CustomOptionFieldChoice(SMCLicensees.TecMagik),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Cybersoft),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Psygnosis),
|
||||
new CustomOptionFieldChoice(SMCLicensees.Davidson),
|
||||
}));
|
||||
|
||||
_dfr.Filters.Add("Nintendo SNES executable", new string[] { "*.smc", "*.sfc", "*.swc", "*.fig", "*.ufo", "*.?gm" });
|
||||
_dfr.Sources.Add("http://romhack.wikia.com/wiki/SNES_ROM_layout");
|
||||
_dfr.Sources.Add("http://romhack.wikia.com/wiki/SNES_header");
|
||||
@ -28,12 +236,29 @@ namespace UniversalEditor.DataFormats.Executable.Nintendo.SNES
|
||||
private SMCExtendedHeader mvarExtendedHeader = new SMCExtendedHeader();
|
||||
public SMCExtendedHeader ExtendedHeader { get { return mvarExtendedHeader; } }
|
||||
|
||||
private SMCRegion mvarRegion = SMCRegions.Japan;
|
||||
/// <summary>
|
||||
/// The region in which the game is licensed.
|
||||
/// </summary>
|
||||
public SMCRegion Region { get { return mvarRegion; } set { mvarRegion = value; } }
|
||||
|
||||
private SMCLicensee mvarLicensee = SMCLicensees.None;
|
||||
/// <summary>
|
||||
/// The licensed organization that developed the game.
|
||||
/// </summary>
|
||||
public SMCLicensee Licensee { get { return mvarLicensee; } set { mvarLicensee = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Loads game data into the specified <see cref="ObjectModel" />.
|
||||
/// </summary>
|
||||
/// <param name="objectModel">The <see cref="ObjectModel" /> into which to load the data.</param>
|
||||
protected override void LoadInternal(ref ObjectModel objectModel)
|
||||
{
|
||||
ExecutableObjectModel exe = (objectModel as ExecutableObjectModel);
|
||||
if (exe == null) throw new ObjectModelNotSupportedException();
|
||||
|
||||
Reader reader = base.Accessor.Reader;
|
||||
|
||||
|
||||
mvarExtendedHeader.Enabled = (base.Accessor.Length % 1024 == 512);
|
||||
if (mvarExtendedHeader.Enabled)
|
||||
@ -117,15 +342,50 @@ namespace UniversalEditor.DataFormats.Executable.Nintendo.SNES
|
||||
// Country code, which selects the video in the emulator. Values $00, $01, $0d use NTSC.
|
||||
// Values in range $02..$0c use PAL. Other values are invalid.
|
||||
byte countryCode = reader.ReadByte();
|
||||
mvarRegion = SMCRegion.FromCode(countryCode);
|
||||
|
||||
// Licensee code. If this value is $33, then the ROM has an extended header with ID at
|
||||
// $ffb2..$ffb5.
|
||||
byte licenseeCode = reader.ReadByte();
|
||||
mvarLicensee = SMCLicensee.FromCode(licenseeCode);
|
||||
|
||||
if (licenseeCode == 0x33)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
byte versionNumber = reader.ReadByte();
|
||||
|
||||
ushort checksumComplement = reader.ReadUInt16();
|
||||
ushort checksum = reader.ReadUInt16();
|
||||
|
||||
int checksumCheck = ((int)checksum + (int)checksumComplement);
|
||||
if (checksumCheck != 0xFFFF) throw new InvalidDataFormatException("Invalid checksum/checksum complement pair");
|
||||
|
||||
int unknown2 = reader.ReadInt32();
|
||||
|
||||
short nativeInterruptVectorCOP = reader.ReadInt16();
|
||||
short nativeInterruptVectorBRK = reader.ReadInt16();
|
||||
short nativeInterruptVectorABORT = reader.ReadInt16();
|
||||
short nativeInterruptVectorNMI = reader.ReadInt16(); // vertical blank
|
||||
short nativeInterruptVectorUnused = reader.ReadInt16();
|
||||
short nativeInterruptVectorIRQ = reader.ReadInt16();
|
||||
|
||||
int unknown3 = reader.ReadInt32();
|
||||
|
||||
short emulationInterruptVectorCOP = reader.ReadInt16();
|
||||
short emulationInterruptVectorUnused = reader.ReadInt16();
|
||||
short emulationInterruptVectorABORT = reader.ReadInt16();
|
||||
short emulationInterruptVectorNMI = reader.ReadInt16(); // vertical blank
|
||||
short emulationInterruptVectorRESET = reader.ReadInt16();
|
||||
short emulationInterruptVectorIRQorBRK = reader.ReadInt16();
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves game data from the specified <see cref="ObjectModel" />.
|
||||
/// </summary>
|
||||
/// <param name="objectModel">The <see cref="ObjectModel" /> from which to save the data.</param>
|
||||
protected override void SaveInternal(ObjectModel objectModel)
|
||||
{
|
||||
ExecutableObjectModel exe = (objectModel as ExecutableObjectModel);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,173 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using UniversalEditor.Common;
|
||||
|
||||
namespace UniversalEditor.DataFormats.Executable.Nintendo.SNES
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <filterpriority>1</filterpriority>
|
||||
/// <completionlist cref="T:UniversalEditor.DataFormats.Executable.Nintendo.SNES.SMCRegions" />
|
||||
public class SMCRegion
|
||||
{
|
||||
private string mvarTitle = String.Empty;
|
||||
/// <summary>
|
||||
/// The human-readable title of this <see cref="SMCRegion" />.
|
||||
/// </summary>
|
||||
public string Title { get { return mvarTitle; } set { mvarTitle = value; } }
|
||||
|
||||
private byte mvarValue = 0;
|
||||
/// <summary>
|
||||
/// The single-byte code that corresponds to this <see cref="SMCRegion" /> in the SMC data
|
||||
/// format.
|
||||
/// </summary>
|
||||
public byte Value { get { return mvarValue; } set { mvarValue = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new <see cref="SMCRegion" /> with the specified title and value.
|
||||
/// </summary>
|
||||
/// <param name="title">The human-readable title of this <see cref="SMCRegion" />.</param>
|
||||
/// <param name="value">The single-byte code that corresponds to this <see cref="SMCRegion" /> in the SMC data format.</param>
|
||||
public SMCRegion(string title, byte value)
|
||||
{
|
||||
mvarTitle = title;
|
||||
mvarValue = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="SMCRegion" /> with the given region code if valid.
|
||||
/// </summary>
|
||||
/// <param name="value">The region code to search on.</param>
|
||||
/// <returns>If the region code is known, returns an instance of the associated <see cref="SMCRegion" />. Otherwise, returns null.</returns>
|
||||
public static SMCRegion FromCode(byte value)
|
||||
{
|
||||
Type t = typeof(SMCRegions);
|
||||
|
||||
MethodAttributes methodAttributes = MethodAttributes.Public | MethodAttributes.Static;
|
||||
PropertyInfo[] properties = t.GetProperties();
|
||||
for (int i = 0; i < properties.Length; i++)
|
||||
{
|
||||
PropertyInfo propertyInfo = properties[i];
|
||||
if (propertyInfo.PropertyType == typeof(SMCRegion))
|
||||
{
|
||||
MethodInfo getMethod = propertyInfo.GetGetMethod();
|
||||
if (getMethod != null && (getMethod.Attributes & methodAttributes) == methodAttributes)
|
||||
{
|
||||
object[] index = null;
|
||||
SMCRegion val = (SMCRegion)propertyInfo.GetValue(null, index);
|
||||
|
||||
if (val.Value == value) return val;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Translates this <see cref="SMCRegion" /> into a human-readable string, including the
|
||||
/// title of the region and the country code.
|
||||
/// </summary>
|
||||
/// <returns>A human-readable string representing this <see cref="SMCRegion" />.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return mvarTitle + " (0x" + mvarValue.ToString("X").PadLeft(2, '0') + ")";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Regions that have been defined by the SNES SMC data format. This class cannot be inherited.
|
||||
/// </summary>
|
||||
public sealed class SMCRegions
|
||||
{
|
||||
private static SMCRegion mvarJapan = new SMCRegion("Japan (NTSC)", 0x00);
|
||||
/// <summary>
|
||||
/// Gets the <see cref="SMCRegion" /> representing "Japan (NTSC)".
|
||||
/// </summary>
|
||||
public static SMCRegion Japan { get { return mvarJapan; } }
|
||||
|
||||
private static SMCRegion mvarNorthAmerica = new SMCRegion("USA and Canada (NTSC)", 0x01);
|
||||
/// <summary>
|
||||
/// Gets the <see cref="SMCRegion" /> representing "USA and Canada (NTSC)".
|
||||
/// </summary>
|
||||
public static SMCRegion NorthAmerica { get { return mvarNorthAmerica; } }
|
||||
|
||||
private static SMCRegion mvarEurasia = new SMCRegion("Europe, Oceania, and Asia (PAL)", 0x02);
|
||||
/// <summary>
|
||||
/// Gets the <see cref="SMCRegion" /> representing "Europe, Oceania, and Asia (PAL)".
|
||||
/// </summary>
|
||||
public static SMCRegion Eurasia { get { return mvarEurasia; } }
|
||||
|
||||
private static SMCRegion mvarSweden = new SMCRegion("Sweden (PAL)", 0x03);
|
||||
/// <summary>
|
||||
/// Gets the <see cref="SMCRegion" /> representing "Sweden (PAL)".
|
||||
/// </summary>
|
||||
public static SMCRegion Sweden { get { return mvarSweden; } }
|
||||
|
||||
private static SMCRegion mvarFinland = new SMCRegion("Finland (PAL)", 0x04);
|
||||
/// <summary>
|
||||
/// Gets the <see cref="SMCRegion" /> representing "Finland (PAL)".
|
||||
/// </summary>
|
||||
public static SMCRegion Finland { get { return mvarFinland; } }
|
||||
|
||||
private static SMCRegion mvarDenmark = new SMCRegion("Denmark (PAL)", 0x05);
|
||||
/// <summary>
|
||||
/// Gets the <see cref="SMCRegion" /> representing "Denmark (PAL)".
|
||||
/// </summary>
|
||||
public static SMCRegion Denmark { get { return mvarDenmark; } }
|
||||
|
||||
private static SMCRegion mvarFrance = new SMCRegion("France (PAL)", 0x06);
|
||||
/// <summary>
|
||||
/// Gets the <see cref="SMCRegion" /> representing "France (PAL)".
|
||||
/// </summary>
|
||||
public static SMCRegion France { get { return mvarFrance; } }
|
||||
|
||||
private static SMCRegion mvarHolland = new SMCRegion("Holland (PAL)", 0x07);
|
||||
/// <summary>
|
||||
/// Gets the <see cref="SMCRegion" /> representing "Holland (PAL)".
|
||||
/// </summary>
|
||||
public static SMCRegion Holland { get { return mvarHolland; } }
|
||||
|
||||
private static SMCRegion mvarSpain = new SMCRegion("Spain (PAL)", 0x08);
|
||||
/// <summary>
|
||||
/// Gets the <see cref="SMCRegion" /> representing "Spain (PAL)".
|
||||
/// </summary>
|
||||
public static SMCRegion Spain { get { return mvarSpain; } }
|
||||
|
||||
private static SMCRegion mvarGermanyAustriaSwitzerland = new SMCRegion("Germany, Austria, and Switzerland (PAL)", 0x09);
|
||||
/// <summary>
|
||||
/// Gets the <see cref="SMCRegion" /> representing "Germany, Austria, and Switzerland (PAL)".
|
||||
/// </summary>
|
||||
public static SMCRegion GermanyAustriaSwitzerland { get { return mvarGermanyAustriaSwitzerland; } }
|
||||
|
||||
private static SMCRegion mvarItaly = new SMCRegion("Italy (PAL)", 0x0A);
|
||||
/// <summary>
|
||||
/// Gets the <see cref="SMCRegion" /> representing "Italy (PAL)".
|
||||
/// </summary>
|
||||
public static SMCRegion Italy { get { return mvarItaly; } }
|
||||
|
||||
private static SMCRegion mvarHongKongAndChina = new SMCRegion("Hong Kong and China (PAL)", 0x0B);
|
||||
/// <summary>
|
||||
/// Gets the <see cref="SMCRegion" /> representing "Hong Kong and China (PAL)".
|
||||
/// </summary>
|
||||
public static SMCRegion HongKongAndChina { get { return mvarHongKongAndChina; } }
|
||||
|
||||
private static SMCRegion mvarIndonesia = new SMCRegion("Indonesia (PAL)", 0x0C);
|
||||
/// <summary>
|
||||
/// Gets the <see cref="SMCRegion" /> representing "Indonesia (PAL)".
|
||||
/// </summary>
|
||||
public static SMCRegion Indonesia { get { return mvarIndonesia; } }
|
||||
|
||||
private static SMCRegion mvarSouthKorea = new SMCRegion("South Korea (NTSC)", 0x0D);
|
||||
/// <summary>
|
||||
/// Gets the <see cref="SMCRegion" /> representing "South Korea (NTSC)".
|
||||
/// </summary>
|
||||
public static SMCRegion SouthKorea { get { return mvarSouthKorea; } }
|
||||
|
||||
// UNK 0x0E
|
||||
// UNK 0x0F
|
||||
}
|
||||
}
|
||||
@ -21,6 +21,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>..\..\Output\Debug\Plugins\UniversalEditor.Plugins.Nintendo.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@ -37,6 +38,8 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="DataFormats\Executable\Nintendo\SNES\SMCDataFormat.cs" />
|
||||
<Compile Include="DataFormats\Executable\Nintendo\SNES\SMCExtendedHeader.cs" />
|
||||
<Compile Include="DataFormats\Executable\Nintendo\SNES\SMCLicensee.cs" />
|
||||
<Compile Include="DataFormats\Executable\Nintendo\SNES\SMCRegion.cs" />
|
||||
<Compile Include="DataFormats\Executable\Nintendo\SNES\SMCSaveRAMSize.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user