From bc05122b12da25b30f011d5ef6a2277863413b50 Mon Sep 17 00:00:00 2001 From: Alexey 'Cluster' Avdyukhin Date: Fri, 4 Nov 2022 10:54:34 +0400 Subject: Comments and minor changes --- FdsBlockDiskInfo.cs | 660 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 622 insertions(+), 38 deletions(-) (limited to 'FdsBlockDiskInfo.cs') diff --git a/FdsBlockDiskInfo.cs b/FdsBlockDiskInfo.cs index 9fbf5df..acef5e3 100644 --- a/FdsBlockDiskInfo.cs +++ b/FdsBlockDiskInfo.cs @@ -1,76 +1,637 @@ using System; +using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Text; namespace com.clusterrr.Famicom.Containers { + /// + /// Disk info FDS block (block type 1) + /// [StructLayout(LayoutKind.Sequential, Size = 58, Pack = 1)] public class FdsBlockDiskInfo : IFdsBlock, IEquatable { + /// + /// Disk side + /// public enum DiskSides { + /// + /// Side A + /// A = 0, + /// + /// Side B + /// B = 1, } + /// + /// Disk type + /// public enum DiskTypes { - FMS = 0, // Normal - FSC = 1, // With shutter + /// + /// Normal + /// + FMS = 0, + /// + /// With shutter + /// + FSC = 1, } + /// + /// Country + /// public enum Country { + /// + /// Japan + /// Japan = 0x49, } - public enum Manufacturer + /// + /// Company name, source: https://www.nesdev.org/wiki/Licensee_codes + /// + public enum Company { - Unlicensed = 0x00, + /// + /// Nintendo + /// Nintendo = 0x01, + /// + /// Nomura Securities? (unverified) + /// + NomuraSecurities = 0x07, + /// + /// Capcom + /// Capcom = 0x08, + /// + /// Hot-B + /// + HotB = 0x09, + /// + /// Jaleco + /// Jaleco = 0x0A, - Hudson_Soft = 0x18, + /// + /// Coconuts Japan Entertainment + /// + CoconutsJapanEntertainment = 0x0B, + /// + /// Electronic Arts (Japan) + /// + ElectronicArtsJap = 0x13, + /// + /// Hudson Soft + /// + HudsonSoft = 0x18, + /// + /// Tokai Engineering + /// + TokaiEngineering = 0x21, + /// + /// Kemco (Japan) + /// + KemcoJap = 0x28, + /// + /// SETA (Japan) + /// + SetaJap = 0x29, + /// + /// Tamtex + /// + Tamtex = 0x2B, + /// + /// Hector Playing Interface (Hect) + /// + HectorPlayingInterface = 0x35, + /// + /// Loriciel + /// + Loriciel = 0x3D, + /// + /// Gremlin + /// + Gremlin = 0x3E, + /// + /// Seika Corporation + /// + SeikaCorporation = 0x40, + /// + /// Ubisoft + /// + Ubisoft = 0x41, + /// + /// System 3 + /// + System3 = 0x46, + /// + /// Irem + /// Irem = 0x49, + /// + /// Gakken + /// Gakken = 0x4A, - BulletProof_Software = 0x8B, - PackInVideo = 0x99, + /// + /// Absolute + /// + Absolute = 0x50, + /// + /// Acclaim (NA) + /// + AcclaimNA = 0x51, + /// + /// Activision + /// + Activision = 0x52, + /// + /// American Sammy + /// + AmericanSammy = 0x53, + /// + /// GameTek + /// + Gametek = 0x54, + /// + /// Hi Tech Expressions + /// + HITechExpressions = 0x55, + /// + /// LJN + /// + Ljn = 0x56, + /// + /// Matchbox Toys + /// + MatchboxToys = 0x57, + /// + /// Mattel + /// + Mattel = 0x58, + /// + /// Milton Bradley + /// + MiltonBradley = 0x59, + /// + /// Mindscape / Software Toolworks + /// + MindscapeSoftwareToolworks = 0x5A, + /// + /// SETA (NA) + /// + SetaNA = 0x5B, + /// + /// Taxan + /// + Taxan = 0x5C, + /// + /// Tradewest + /// + Tradewest = 0x5D, + /// + /// INTV Corporation + /// + IntvCorporation = 0x5E, + /// + /// Titus + /// + Titus = 0x60, + /// + /// Virgin Games + /// + VirginGames = 0x61, + /// + /// Ocean + /// + Ocean = 0x67, + /// + /// Electronic Arts (NA) + /// + ElectronicArtsNA = 0x69, + /// + /// Beam Software + /// + BeamSoftware = 0x6B, + /// + /// Elite Systems + /// + EliteSystems = 0x6E, + /// + /// Electro Brain + /// + ElectroBrain = 0x6F, + /// + /// Infogrames + /// + Infogrames = 0x70, + /// + /// JVC + /// + Jvc = 0x72, + /// + /// Parker Brothers + /// + ParkerBrothers = 0x73, + /// + /// The Sales Curve / SCi + /// + TheSalesCurveSci = 0x75, + /// + /// THQ + /// + Thq = 0x78, + /// + /// Accolade + /// + Accolade = 0x79, + /// + /// Triffix + /// + Triffix = 0x7A, + /// + /// Microprose Software + /// + MicroproseSoftware = 0x7C, + /// + /// Kemco (NA) + /// + KemcoNA = 0x7F, + /// + /// Misawa Entertainment + /// + MisawaEntertainment = 0x80, + /// + /// G. Amusements Co. + /// + GAmusementsCO = 0x83, + /// + /// G.O 1 + /// + GO1 = 0x85, + /// + /// Tokuma Shoten Intermedia + /// + TokumaShotenIntermedia = 0x86, + /// + /// Nihon Maicom Kaihatsu (NMK) + /// + NihonMaicomKaihatsu = 0x89, + /// + /// BulletProof Software (BPS) + /// + BulletproofSoftware = 0x8B, + /// + /// VIC Tokai + /// + VicTokai = 0x8C, + /// + /// Sanritsu + /// + Sanritsu = 0x8D, + /// + /// Character Soft + /// + CharacterSoft = 0x8E, + /// + /// I'Max + /// + IMax = 0x8F, + /// + /// Toaplan + /// + Toaplan = 0x94, + /// + /// Varie + /// + Varie = 0x95, + /// + /// Yonezawa Party Room 21 / S'Pal + /// + YonezawaPartyRoom21SPal = 0x96, + /// + /// Pack-In-Video + /// + PackINVideo = 0x99, + /// + /// Nihon Bussan + /// + NihonBussan = 0x9A, + /// + /// Tecmo + /// Tecmo = 0x9B, + /// + /// Imagineer + /// Imagineer = 0x9C, - Scorpion_Soft = 0xA2, + /// + /// Face + /// + Face = 0x9E, + /// + /// Scorpion Soft + /// + ScorpionSoft = 0xA2, + /// + /// Broderbund + /// + Broderbund = 0xA3, + /// + /// Konami + /// Konami = 0xA4, - Kawada_Co = 0xA6, + /// + /// K. Amusement Leasing Co. (KAC) + /// + KAmusementLeasingCO = 0xA5, + /// + /// Kawada Co., Ltd. + /// + KawadaCOLtd = 0xA6, + /// + /// Takara + /// Takara = 0xA7, - Royal_Industries = 0xA8, - Toei_Animation = 0xAC, + /// + /// Royal Industries + /// + RoyalIndustries = 0xA8, + /// + /// Tecnos + /// + Tecnos = 0xA9, + /// + /// Victor Musical Industries + /// + VictorMusicalIndustries = 0xAA, + /// + /// Hi-Score Media Work + /// + HIScoreMediaWork = 0xAB, + /// + /// Toei Animation + /// + ToeiAnimation = 0xAC, + /// + /// Toho (Japan) + /// + TohoJap = 0xAD, + /// + /// TSS + /// + Tss = 0xAE, + /// + /// Namco + /// Namco = 0xAF, - ASCII_Corporation = 0xB1, + /// + /// Acclaim (Japan) + /// + AcclaimJap = 0xB0, + /// + /// ASCII Corporation / Nexoft + /// + AsciiCorporationNexoft = 0xB1, + /// + /// Bandai + /// Bandai = 0xB2, - Soft_Pro_Inc = 0xB3, - HAL_Laboratory = 0xB6, - Sunsoft_and_Ask_Co = 0xBB, - Toshiba_EMI = 0xBC, + /// + /// Soft Pro Inc. + /// + SoftProInc = 0xB3, + /// + /// Enix + /// + Enix = 0xB4, + /// + /// dB-SOFT + /// + DBSoft = 0xB5, + /// + /// HAL Laboratory + /// + HalLaboratory = 0xB6, + /// + /// SNK + /// + Snk = 0xB7, + /// + /// Pony Canyon + /// + PonyCanyon = 0xB9, + /// + /// Culture Brain + /// + CultureBrain = 0xBA, + /// + /// Sunsoft + /// + Sunsoft = 0xBB, + /// + /// Toshiba EMI + /// + ToshibaEmi = 0xBC, + /// + /// CBS/Sony Group + /// + CbsSonyGroup = 0xBD, + /// + /// Sammy Corporation + /// + SammyCorporation = 0xBF, + /// + /// Taito + /// Taito = 0xC0, - Sunsoft = 0xC1, + /// + /// Sunsoft / Ask Co., Ltd. + /// + SunsoftAskCOLtd = 0xC1, + /// + /// Kemco + /// Kemco = 0xC2, - Square = 0xC3, - Tokuma_Shoten = 0xC4, - Data_East = 0xC5, - Tonkin_House_and_Tokyo_Shoseki = 0xC6, - East_Cube = 0xC7, - Konami_and_Ultra_and_Palcom = 0xCA, - NTVIC_and_VAP = 0xCB, - Use_Co = 0xCC, - Pony_Canyon_and_FCI = 0xCE, + /// + /// Square / Disk Original Group (DOG) + /// + SquareDiskOriginalGroup = 0xC3, + /// + /// Tokuma Shoten + /// + TokumaShoten = 0xC4, + /// + /// Data East + /// + DataEast = 0xC5, + /// + /// Tonkin House / Tokyo Shoseki + /// + TonkinHouseTokyoShoseki = 0xC6, + /// + /// East Cube / Toho (NA) + /// + EastCubeTohoNA = 0xC7, + /// + /// Koei + /// + Koei = 0xC8, + /// + /// UPL + /// + Upl = 0xC9, + /// + /// Konami / Ultra / Palcom + /// + KonamiUltraPalcom = 0xCA, + /// + /// NTVIC / VAP + /// + NtvicVap = 0xCB, + /// + /// Use Co., Ltd. + /// + UseCOLtd = 0xCC, + /// + /// Meldac + /// + Meldac = 0xCD, + /// + /// Pony Canyon / FCI + /// + PonyCanyonFci = 0xCE, + /// + /// Angel + /// + Angel = 0xCF, + /// + /// Disco + /// + Disco = 0xD0, + /// + /// Sofel + /// Sofel = 0xD1, - Bothtec_Inc = 0xD2, - Hiro_Co = 0xDB, + /// + /// Bothtec, Inc. / Quest + /// + BothtecIncQuest = 0xD2, + /// + /// Sigma Enterprises + /// + SigmaEnterprises = 0xD3, + /// + /// Ask Corp. + /// + AskCorp = 0xD4, + /// + /// Kyugo Trading Co. + /// + KyugoTradingCO = 0xD5, + /// + /// Naxat Soft / Kaga Tech + /// + NaxatSoftKagaTech = 0xD6, + /// + /// Status + /// + Status = 0xD8, + /// + /// Banpresto + /// + Banpresto = 0xD9, + /// + /// Tomy + /// + Tomy = 0xDA, + /// + /// Hiro Co., Ltd. + /// + HiroCOLtd = 0xDB, + /// + /// Nippon Computer Systems (NCS) / Masaya Games + /// + NipponComputerSystemsMasayaGames = 0xDD, + /// + /// Human Creative + /// + HumanCreative = 0xDE, + /// + /// Altron + /// + Altron = 0xDF, + /// + /// K.K. DCE + /// + KKDce = 0xE0, + /// + /// Towa Chiki + /// + TowaChiki = 0xE1, + /// + /// Yutaka + /// + Yutaka = 0xE2, + /// + /// Kaken Corporation + /// + KakenCorporation = 0xE3, + /// + /// Epoch + /// + Epoch = 0xE5, + /// + /// Athena + /// Athena = 0xE7, + /// + /// Asmik + /// + Asmik = 0xE8, + /// + /// Natsume + /// + Natsume = 0xE9, + /// + /// King Records + /// + KingRecords = 0xEA, + /// + /// Atlus + /// Atlus = 0xEB, + /// + /// Sony Music Entertainment + /// + SonyMusicEntertainment = 0xEC, + /// + /// Pixel Corporation + /// + PixelCorporation = 0xED, + /// + /// Information Global Service (IGS) + /// + InformationGlobalService = 0xEE, + /// + /// Fujimic + /// + Fujimic = 0xEF, + /// + /// A-Wave + /// + AWave = 0xF0, } [MarshalAs(UnmanagedType.U1)] // Raw byte: 0x01 private readonly byte blockType = 1; + /// + /// Valid block type ID + /// public byte ValidTypeID { get => 1; } /// /// True if block type ID is valid @@ -89,7 +650,7 @@ namespace com.clusterrr.Famicom.Containers /// /// Manufacturer code. = = 0x00, Unlicensed, = = 0x01, Nintendo /// - public Manufacturer ManufacturerCode { get => (Manufacturer)manufacturerCode; set => manufacturerCode = (byte)value; } + public Company LicenseeCode { get => (Company)manufacturerCode; set => manufacturerCode = (byte)value; } [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] byte[] gameName; @@ -309,32 +870,46 @@ namespace com.clusterrr.Famicom.Containers /// public bool EndOfHeadMeet { get => endOfHeadMeet; set => endOfHeadMeet = value; } - public uint Length => 56; + /// + /// Length of the block + /// + public uint Length { get => 56; } - public static FdsBlockDiskInfo FromBytes(byte[] rawData, int position = 0) + /// + /// Create FdsBlockDiskInfo object from raw data + /// + /// Data + /// Data offset + /// FdsBlockDiskInfo object + /// + public static FdsBlockDiskInfo FromBytes(byte[] data, int offset = 0) { int rawsize = Marshal.SizeOf(typeof(FdsBlockDiskInfo)); - if (rawsize > rawData.Length - position) + if (rawsize > data.Length - offset) { - if (rawsize <= rawData.Length - position + 2) + if (rawsize <= data.Length - offset + 2) { var newRawData = new byte[rawsize]; - Array.Copy(rawData, position, newRawData, 0, rawsize - 2); - rawData = newRawData; - position = 0; + Array.Copy(data, offset, newRawData, 0, rawsize - 2); + data = newRawData; + offset = 0; } else { - throw new ArgumentException("Not enough data to fill FdsDiskInfoBlock class. Array length from position: " + (rawData.Length - position) + ", Struct length: " + rawsize); + throw new InvalidDataException("Not enough data to fill FdsDiskInfoBlock class. Array length from position: " + (data.Length - offset) + ", struct length: " + rawsize); } } IntPtr buffer = Marshal.AllocHGlobal(rawsize); - Marshal.Copy(rawData, position, buffer, rawsize); + Marshal.Copy(data, offset, buffer, rawsize); FdsBlockDiskInfo retobj = (FdsBlockDiskInfo)Marshal.PtrToStructure(buffer, typeof(FdsBlockDiskInfo)); Marshal.FreeHGlobal(buffer); return retobj; } + /// + /// Return raw data + /// + /// Data public byte[] ToBytes() { int rawSize = Marshal.SizeOf(this); @@ -346,8 +921,17 @@ namespace com.clusterrr.Famicom.Containers return rawDatas; } + /// + /// String representation + /// + /// Game name public override string ToString() => GameName; + /// + /// Equality comparer + /// + /// Other FdsBlockDiskInfo object + /// True if objects are equal public bool Equals(FdsBlockDiskInfo other) { return Enumerable.SequenceEqual(this.ToBytes(), other.ToBytes()); -- cgit v1.2.3