Skip to content

Commit

Permalink
Date parsing fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ClusterM committed Sep 4, 2023
1 parent e44349e commit 0859cf1
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 60 deletions.
30 changes: 15 additions & 15 deletions FdsBlockDiskInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ public string? GameName {
[MarshalAs(UnmanagedType.U1)]
byte unknown02 = 0xFF;
/// <summary>
/// Unknown, offset 0x1A.
/// Unknown, offset 0x1A.
/// Always 0xFF
/// </summary>
public byte Unknown02 { get => unknown02; set => unknown02 = value; }
Expand Down Expand Up @@ -783,7 +783,7 @@ public string? GameName {
[MarshalAs(UnmanagedType.U1)]
byte unknown06 = 0xFF;
/// <summary>
/// Unknown, offset 0x1E.
/// Unknown, offset 0x1E.
/// Always 0xFF
/// </summary>
public byte Unknown06 { get => unknown06; set => unknown06 = value; }
Expand All @@ -799,7 +799,7 @@ public DateTime? ManufacturingDate
{
try
{
if (rewrittenDate.Where(b => b != 0).Any())
if (manufacturingDate.Where(b => b != 0).Any())
return new DateTime(
((manufacturingDate[0] & 0x0F) + ((manufacturingDate[0] >> 4) & 0x0F) * 10) + 1925,
((manufacturingDate[1] & 0x0F) + ((manufacturingDate[1] >> 4) & 0x0F) * 10),
Expand All @@ -819,9 +819,9 @@ public DateTime? ManufacturingDate
{
manufacturingDate = new byte[]
{
(byte)(((value.Value.Year - 1925) % 10) | (((value.Value.Year - 1925) / 10) << 4)),
(byte)(((value.Value.Month) % 10) | (((value.Value.Month) / 10) << 4)),
(byte)(((value.Value.Day) % 10) | (((value.Value.Day) / 10) << 4))
(byte)(((value.Value.Year - 1925) % 10) | (((value.Value.Year - 1925) / 10) << 4)),
(byte)(((value.Value.Month) % 10) | (((value.Value.Month) / 10) << 4)),
(byte)(((value.Value.Day) % 10) | (((value.Value.Day) / 10) << 4))
};
} else
{
Expand All @@ -840,7 +840,7 @@ public DateTime? ManufacturingDate
[MarshalAs(UnmanagedType.U1)]
byte unknown07 = 0x61;
/// <summary>
/// Unknown, offset 0x23.
/// Unknown, offset 0x23.
/// Always 0x61.
/// Speculative: Region code?
/// </summary>
Expand All @@ -849,7 +849,7 @@ public DateTime? ManufacturingDate
[MarshalAs(UnmanagedType.U1)]
byte unknown08 = 0x00;
/// <summary>
/// Unknown, offset 0x24.
/// Unknown, offset 0x24.
/// Always 0x00.
/// Speculative: Location/site?
/// </summary>
Expand All @@ -866,7 +866,7 @@ public DateTime? ManufacturingDate
[MarshalAs(UnmanagedType.U1)]
byte unknown10 = 0x02;
/// <summary>
/// Unknown, offset 0x26.
/// Unknown, offset 0x26.
/// Always 0x02
/// </summary>
public byte Unknown10 { get => unknown10; set => unknown10 = value; }
Expand Down Expand Up @@ -937,7 +937,7 @@ public DateTime? RewrittenDate
{
if (value != null)
{
manufacturingDate = new byte[]
rewrittenDate = new byte[]
{
(byte)(((value.Value.Year - 1925) % 10) | (((value.Value.Year - 1925) / 10) << 4)),
(byte)(((value.Value.Month) % 10) | (((value.Value.Month) / 10) << 4)),
Expand All @@ -946,7 +946,7 @@ public DateTime? RewrittenDate
}
else
{
manufacturingDate = new byte[3];
rewrittenDate = new byte[3];
}
}
}
Expand All @@ -961,7 +961,7 @@ public DateTime? RewrittenDate
[MarshalAs(UnmanagedType.U1)]
byte unknown17 = 0x80;
/// <summary>
/// Unknown, offset 0x30.
/// Unknown, offset 0x30.
/// Always 0x80
/// </summary>
public byte Unknown17 { get => unknown17; set => unknown17 = value; }
Expand All @@ -975,15 +975,15 @@ public DateTime? RewrittenDate
[MarshalAs(UnmanagedType.U1)]
byte unknown18 = 0x07;
/// <summary>
/// Unknown, offset 0x33, unknown.
/// Unknown, offset 0x33, unknown.
/// Always 0x07
/// </summary>
public byte Unknown18 { get => unknown18; set => unknown18 = value; }

[MarshalAs(UnmanagedType.U1)]
byte diskRewriteCount = 0x00;
/// <summary>
/// Disk rewrite count.
/// Disk rewrite count.
/// 0x00 = Original (no copies)
/// </summary>
public byte DiskRewriteCount
Expand Down Expand Up @@ -1021,7 +1021,7 @@ public byte DiskRewriteCount
public byte Price { get => price; set => price = value; }

/// <summary>
/// Unknown how this differs from GameVersion. Disk version numbers indicate different software revisions.
/// Unknown how this differs from GameVersion. Disk version numbers indicate different software revisions.
/// Speculation is that disk version incremented with each disk received from a licensee
/// </summary>
public byte DiskVersion { get => price; set => price = value; }
Expand Down
84 changes: 42 additions & 42 deletions FdsDiskSide.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class FdsDiskSide
/// <summary>
/// Manufacturer code. 0x00 = Unlicensed, 0x01 = Nintendo
/// </summary>
public Company LicenseeCode { get => diskInfoBlock.LicenseeCode; set => diskInfoBlock.LicenseeCode = value; }
public Company LicenseeCode { get => diskInfoBlock.LicenseeCode; set => diskInfoBlock.LicenseeCode = value; }

/// <summary>
/// 3-letter ASCII code per game (e.g. ZEL for The Legend of Zelda)
Expand All @@ -38,68 +38,68 @@ public class FdsDiskSide
/// 0x45 = "E" — Event(e.g.Japanese national DiskFax tournaments)
/// 0x52 = "R" — Reduction in price via advertising
/// </summary>
public char GameType { get => diskInfoBlock.GameType; set => diskInfoBlock.GameType = value; }
public char GameType { get => diskInfoBlock.GameType; set => diskInfoBlock.GameType = value; }

/// <summary>
/// Game version/revision number. Starts at 0x00, increments per revision
/// </summary>
public byte GameVersion { get => diskInfoBlock.GameVersion; set => diskInfoBlock.GameVersion = value; }
public byte GameVersion { get => diskInfoBlock.GameVersion; set => diskInfoBlock.GameVersion = value; }

/// <summary>
/// Side number. Single-sided disks use A
/// </summary>
public DiskSides DiskSide { get => diskInfoBlock.DiskSide; set => diskInfoBlock.DiskSide = value; }
public DiskSides DiskSide { get => diskInfoBlock.DiskSide; set => diskInfoBlock.DiskSide = value; }

/// <summary>
/// Disk number. First disk is 0x00, second is 0x01, etc.
/// </summary>
public byte DiskNumber { get => diskInfoBlock.DiskNumber; set => diskInfoBlock.DiskNumber = value; }
public byte DiskNumber { get => diskInfoBlock.DiskNumber; set => diskInfoBlock.DiskNumber = value; }

/// <summary>
/// Disk type. 0x00 = FMC ("normal card"), 0x01 = FSC ("card with shutter"). May correlate with FMC and FSC product codes
/// </summary>
public DiskTypes DiskType { get => diskInfoBlock.DiskType; set => diskInfoBlock.DiskType = value; }
public DiskTypes DiskType { get => diskInfoBlock.DiskType; set => diskInfoBlock.DiskType = value; }

/// <summary>
/// Unknown, offset 0x18.
/// Always 0x00
/// </summary>
public byte Unknown01 { get => diskInfoBlock.Unknown01; set => diskInfoBlock.Unknown01 = value; }
public byte Unknown01 { get => diskInfoBlock.Unknown01; set => diskInfoBlock.Unknown01 = value; }

/// <summary>
/// Boot read file code. Refers to the file code/file number to load upon boot/start-up
/// </summary>
public byte BootFile { get => diskInfoBlock.BootFile; set => diskInfoBlock.BootFile = value; }
public byte BootFile { get => diskInfoBlock.BootFile; set => diskInfoBlock.BootFile = value; }

/// <summary>
/// Unknown, offset 0x1A.
/// Unknown, offset 0x1A.
/// Always 0xFF
/// </summary>
public byte Unknown02 { get => diskInfoBlock.Unknown02; set => diskInfoBlock.Unknown02 = value; }
public byte Unknown02 { get => diskInfoBlock.Unknown02; set => diskInfoBlock.Unknown02 = value; }

/// <summary>
/// Unknown, offset 0x1B.
/// Always 0xFF
/// </summary>
public byte Unknown03 { get => diskInfoBlock.Unknown03; set => diskInfoBlock.Unknown03 = value; }
public byte Unknown03 { get => diskInfoBlock.Unknown03; set => diskInfoBlock.Unknown03 = value; }

/// <summary>
/// Unknown, offset 0x1C.
/// Always 0xFF
/// </summary>
public byte Unknown04 { get => diskInfoBlock.Unknown04; set => diskInfoBlock.Unknown04 = value; }
public byte Unknown04 { get => diskInfoBlock.Unknown04; set => diskInfoBlock.Unknown04 = value; }

/// <summary>
/// Unknown, offset 0x1D.
/// Always 0xFF
/// </summary>
public byte Unknown05 { get => diskInfoBlock.Unknown05; set => diskInfoBlock.Unknown05 = value; }
public byte Unknown05 { get => diskInfoBlock.Unknown05; set => diskInfoBlock.Unknown05 = value; }

/// <summary>
/// Unknown, offset 0x1E.
/// Unknown, offset 0x1E.
/// Always 0xFF
/// </summary>
public byte Unknown06 { get => diskInfoBlock.Unknown06; set => diskInfoBlock.Unknown06 = value; }
public byte Unknown06 { get => diskInfoBlock.Unknown06; set => diskInfoBlock.Unknown06 = value; }

/// <summary>
/// Manufacturing date
Expand All @@ -109,58 +109,58 @@ public class FdsDiskSide
/// <summary>
/// Country code. 0x49 = Japan
/// </summary>
public Country CountryCode { get => diskInfoBlock.CountryCode; set => diskInfoBlock.CountryCode = value; }
public Country CountryCode { get => diskInfoBlock.CountryCode; set => diskInfoBlock.CountryCode = value; }

/// <summary>
/// Unknown, offset 0x23.
/// Unknown, offset 0x23.
/// Always 0x61.
/// Speculative: Region code?
/// </summary>
public byte Unknown07 { get => diskInfoBlock.Unknown07; set => diskInfoBlock.Unknown07 = value; }
public byte Unknown07 { get => diskInfoBlock.Unknown07; set => diskInfoBlock.Unknown07 = value; }

/// <summary>
/// Unknown, offset 0x24.
/// Unknown, offset 0x24.
/// Always 0x00.
/// Speculative: Location/site?
/// </summary>
public byte Unknown08 { get => diskInfoBlock.Unknown08; set => diskInfoBlock.Unknown08 = value; }
public byte Unknown08 { get => diskInfoBlock.Unknown08; set => diskInfoBlock.Unknown08 = value; }

/// <summary>
/// Unknown, offset 0x25.
/// Always 0x00
/// </summary>
public byte Unknown09 { get => diskInfoBlock.Unknown09; set => diskInfoBlock.Unknown09 = value; }
public byte Unknown09 { get => diskInfoBlock.Unknown09; set => diskInfoBlock.Unknown09 = value; }

/// <summary>
/// Unknown, offset 0x26.
/// Unknown, offset 0x26.
/// Always 0x02
/// </summary>
public byte Unknown10 { get => diskInfoBlock.Unknown10; set => diskInfoBlock.Unknown10 = value; }
public byte Unknown10 { get => diskInfoBlock.Unknown10; set => diskInfoBlock.Unknown10 = value; }

/// <summary>
/// Unknown, offset 0x27. Speculative: some kind of game information representation?
/// </summary>
public byte Unknown11 { get => diskInfoBlock.Unknown11; set => diskInfoBlock.Unknown11 = value; }
public byte Unknown11 { get => diskInfoBlock.Unknown11; set => diskInfoBlock.Unknown11 = value; }

/// <summary>
/// Unknown, offset 0x28. Speculative: some kind of game information representation?
/// </summary>
public byte Unknown12 { get => diskInfoBlock.Unknown12; set => diskInfoBlock.Unknown12 = value; }
public byte Unknown12 { get => diskInfoBlock.Unknown12; set => diskInfoBlock.Unknown12 = value; }

/// <summary>
/// Unknown, offset 0x29. Speculative: some kind of game information representation?
/// </summary>
public byte Unknown13 { get => diskInfoBlock.Unknown13; set => diskInfoBlock.Unknown13 = value; }
public byte Unknown13 { get => diskInfoBlock.Unknown13; set => diskInfoBlock.Unknown13 = value; }

/// <summary>
/// Unknown, offset 0x2A. Speculative: some kind of game information representation?
/// </summary>
public byte Unknown14 { get => diskInfoBlock.Unknown14; set => diskInfoBlock.Unknown14 = value; }
public byte Unknown14 { get => diskInfoBlock.Unknown14; set => diskInfoBlock.Unknown14 = value; }

/// <summary>
/// Unknown, offset 0x2B. Speculative: some kind of game information representation?
/// </summary>
public byte Unknown15 { get => diskInfoBlock.Unknown15; set => diskInfoBlock.Unknown15 = value; }
public byte Unknown15 { get => diskInfoBlock.Unknown15; set => diskInfoBlock.Unknown15 = value; }

/// <summary>
/// "Rewritten disk" date. It's speculated this refers to the date the disk was formatted and rewritten by something like a Disk Writer kiosk.
Expand All @@ -171,64 +171,64 @@ public class FdsDiskSide
/// <summary>
/// Unknown, offset 0x2F
/// </summary>
public byte Unknown16 { get => diskInfoBlock.Unknown16; set => diskInfoBlock.Unknown16 = value; }
public byte Unknown16 { get => diskInfoBlock.Unknown16; set => diskInfoBlock.Unknown16 = value; }

/// <summary>
/// Unknown, offset 0x30.
/// Unknown, offset 0x30.
/// Always 0x80
/// </summary>
public byte Unknown17 { get => diskInfoBlock.Unknown17; set => diskInfoBlock.Unknown17 = value; }
public byte Unknown17 { get => diskInfoBlock.Unknown17; set => diskInfoBlock.Unknown17 = value; }

/// <summary>
/// Disk Writer serial number
/// </summary>
public ushort DiskWriterSerialNumber { get => diskInfoBlock.DiskWriterSerialNumber; set => diskInfoBlock.DiskWriterSerialNumber = value; }
public ushort DiskWriterSerialNumber { get => diskInfoBlock.DiskWriterSerialNumber; set => diskInfoBlock.DiskWriterSerialNumber = value; }

/// <summary>
/// Unknown, offset 0x33, unknown.
/// Unknown, offset 0x33, unknown.
/// Always 0x07
/// </summary>
public byte Unknown18 { get => diskInfoBlock.Unknown18; set => diskInfoBlock.Unknown18 = value; }
public byte Unknown18 { get => diskInfoBlock.Unknown18; set => diskInfoBlock.Unknown18 = value; }

/// <summary>
/// Disk rewrite count.
/// Disk rewrite count.
/// 0x00 = Original (no copies)
/// </summary>
public byte DiskRewriteCount { get => diskInfoBlock.DiskRewriteCount; set => diskInfoBlock.DiskRewriteCount = value; }

/// <summary>
/// Actual disk side
/// </summary>
public DiskSides ActualDiskSide { get => diskInfoBlock.ActualDiskSide; set => diskInfoBlock.ActualDiskSide = value; }
public DiskSides ActualDiskSide { get => diskInfoBlock.ActualDiskSide; set => diskInfoBlock.ActualDiskSide = value; }

/// <summary>
/// Disk type (other)
/// </summary>
public DiskTypesOther DiskTypeOther { get => diskInfoBlock.DiskTypeOther; set => diskInfoBlock.DiskTypeOther = value; }
public DiskTypesOther DiskTypeOther { get => diskInfoBlock.DiskTypeOther; set => diskInfoBlock.DiskTypeOther = value; }

/// <summary>
/// Price code (deprecated, no backing)
/// </summary>
[Obsolete("Use \"DiskVersion\" property")]
public byte Price { get => diskInfoBlock.DiskVersion; set => diskInfoBlock.DiskVersion = value; }
public byte Price { get => diskInfoBlock.DiskVersion; set => diskInfoBlock.DiskVersion = value; }

/// <summary>
/// Unknown how this differs from GameVersion. Disk version numbers indicate different software revisions.
/// Unknown how this differs from GameVersion. Disk version numbers indicate different software revisions.
/// Speculation is that disk version incremented with each disk received from a licensee
/// </summary>
public byte DiskVersion { get => diskInfoBlock.DiskVersion; set => diskInfoBlock.DiskVersion = value; }
public byte DiskVersion { get => diskInfoBlock.DiskVersion; set => diskInfoBlock.DiskVersion = value; }

readonly FdsBlockFileAmount fileAmountBlock;
/// <summary>
/// Non-hidden file amount
/// </summary>
public byte FileAmount { get => fileAmountBlock.FileAmount; set => fileAmountBlock.FileAmount = value; }
public byte FileAmount { get => fileAmountBlock.FileAmount; set => fileAmountBlock.FileAmount = value; }

readonly IList<FdsDiskFile> files;
/// <summary>
/// Files on disk
/// </summary>
public IList<FdsDiskFile> Files { get => files; }
public IList<FdsDiskFile> Files { get => files; }

/// <summary>
/// Constructor to create empty FdsDiskSide object
Expand Down
6 changes: 3 additions & 3 deletions NesContainers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
<PackageProjectUrl>https://github.com/ClusterM/nes-containers</PackageProjectUrl>
<Copyright>Alexey Cluster, 2023</Copyright>
<Description>A simple .NET Standard 2.0 library for reading and modifying NES/Famicom ROM containers: .nes (iNES, NES 2.0), .unf (UNIF), and .fds (Famicom Disk System images).</Description>
<Version>1.1.7</Version>
<Version>1.1.8</Version>
<RepositoryUrl>https://github.com/ClusterM/nes-containers</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>NES;Famicom;FamicomDiskSystem</PackageTags>
<AssemblyVersion>1.1.7</AssemblyVersion>
<FileVersion>1.1.7</FileVersion>
<AssemblyVersion>1.1.8</AssemblyVersion>
<FileVersion>1.1.8</FileVersion>
<Authors>Alexey Cluster</Authors>
</PropertyGroup>

Expand Down

0 comments on commit 0859cf1

Please sign in to comment.