From b83e538bbb7160798b0410b18509486017c920b9 Mon Sep 17 00:00:00 2001 From: Alexey 'Cluster' Avdyukhin Date: Fri, 4 Nov 2022 14:44:32 +0400 Subject: Removed dumper specific properties --- FdsBlockDiskInfo.cs | 36 +++++------------------------------- FdsBlockFileAmount.cs | 10 ---------- FdsBlockFileHeader.cs | 22 ++++------------------ FdsDiskFile.cs | 2 +- 4 files changed, 10 insertions(+), 60 deletions(-) diff --git a/FdsBlockDiskInfo.cs b/FdsBlockDiskInfo.cs index acef5e3..9f91957 100644 --- a/FdsBlockDiskInfo.cs +++ b/FdsBlockDiskInfo.cs @@ -9,7 +9,7 @@ namespace com.clusterrr.Famicom.Containers /// /// Disk info FDS block (block type 1) /// - [StructLayout(LayoutKind.Sequential, Size = 58, Pack = 1)] + [StructLayout(LayoutKind.Sequential, Size = 56, Pack = 1)] public class FdsBlockDiskInfo : IFdsBlock, IEquatable { /// @@ -856,20 +856,6 @@ namespace com.clusterrr.Famicom.Containers /// public byte Price { get => price; set => price = value; } - [MarshalAs(UnmanagedType.U1)] - private bool crcOk = true; - /// - /// Set by dumper. True when checksum is ok - /// - public bool CrcOk { get => crcOk; set => crcOk = value; } - - [MarshalAs(UnmanagedType.U1)] - private bool endOfHeadMeet = false; - /// - /// Set by dumper. True when "end of head" flag was meet during dumping - /// - public bool EndOfHeadMeet { get => endOfHeadMeet; set => endOfHeadMeet = value; } - /// /// Length of the block /// @@ -886,19 +872,7 @@ namespace com.clusterrr.Famicom.Containers { int rawsize = Marshal.SizeOf(typeof(FdsBlockDiskInfo)); if (rawsize > data.Length - offset) - { - if (rawsize <= data.Length - offset + 2) - { - var newRawData = new byte[rawsize]; - Array.Copy(data, offset, newRawData, 0, rawsize - 2); - data = newRawData; - offset = 0; - } - else - { - throw new InvalidDataException("Not enough data to fill FdsDiskInfoBlock class. Array length from position: " + (data.Length - offset) + ", 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(data, offset, buffer, rawsize); FdsBlockDiskInfo retobj = (FdsBlockDiskInfo)Marshal.PtrToStructure(buffer, typeof(FdsBlockDiskInfo)); @@ -915,10 +889,10 @@ namespace com.clusterrr.Famicom.Containers int rawSize = Marshal.SizeOf(this); IntPtr buffer = Marshal.AllocHGlobal(rawSize); Marshal.StructureToPtr(this, buffer, false); - byte[] rawDatas = new byte[rawSize - 2]; - Marshal.Copy(buffer, rawDatas, 0, rawSize - 2); + byte[] data = new byte[rawSize]; + Marshal.Copy(buffer, data, 0, rawSize); Marshal.FreeHGlobal(buffer); - return rawDatas; + return data; } /// diff --git a/FdsBlockFileAmount.cs b/FdsBlockFileAmount.cs index 47a9d55..868b22e 100644 --- a/FdsBlockFileAmount.cs +++ b/FdsBlockFileAmount.cs @@ -25,16 +25,6 @@ namespace com.clusterrr.Famicom.Containers /// public byte FileAmount { get => fileAmount; set => fileAmount = value; } - /// - /// Set by dumper. True when checksum is ok - /// - public bool CrcOk { get; set; } = true; - - /// - /// Set by dumper. True when "end of head" flag was meet during dumping - /// - public bool EndOfHeadMeet { get; set; } = false; - /// /// Length of the block /// diff --git a/FdsBlockFileHeader.cs b/FdsBlockFileHeader.cs index 6de2f1b..ee0233c 100644 --- a/FdsBlockFileHeader.cs +++ b/FdsBlockFileHeader.cs @@ -9,7 +9,7 @@ namespace com.clusterrr.Famicom.Containers /// /// File header FDS block (block type 3) /// - [StructLayout(LayoutKind.Sequential, Size = 18, Pack = 1)] + [StructLayout(LayoutKind.Sequential, Size = 16, Pack = 1)] public class FdsBlockFileHeader : IFdsBlock, IEquatable { /// @@ -85,20 +85,6 @@ namespace com.clusterrr.Famicom.Containers /// public Kind FileKind { get => (Kind)fileKind; set => fileKind = (byte)value; } - [MarshalAs(UnmanagedType.U1)] - private bool crcOk = true; - /// - /// Set by dumper. True when checksum is ok - /// - public bool CrcOk { get => crcOk; set => crcOk = value; } - - [MarshalAs(UnmanagedType.U1)] - private bool endOfHeadMeet = false; - /// - /// Set by dumper. True when "end of head" flag was meet during dumping - /// - public bool EndOfHeadMeet { get => endOfHeadMeet; set => endOfHeadMeet = value; } - /// /// Length of the block /// @@ -144,10 +130,10 @@ namespace com.clusterrr.Famicom.Containers int rawSize = Marshal.SizeOf(this); IntPtr buffer = Marshal.AllocHGlobal(rawSize); Marshal.StructureToPtr(this, buffer, false); - byte[] rawDatas = new byte[rawSize - 2]; - Marshal.Copy(buffer, rawDatas, 0, rawSize - 2); + byte[] data = new byte[rawSize]; + Marshal.Copy(buffer, data, 0, rawSize); Marshal.FreeHGlobal(buffer); - return rawDatas; + return data; } /// diff --git a/FdsDiskFile.cs b/FdsDiskFile.cs index e05591b..c3c2e53 100644 --- a/FdsDiskFile.cs +++ b/FdsDiskFile.cs @@ -68,7 +68,7 @@ namespace com.clusterrr.Famicom.Containers } /// - /// Construcor for empty file + /// Construcor for empty FdsDiskFile object /// public FdsDiskFile() { -- cgit v1.2.3