initial commit

This commit is contained in:
what 2021-07-26 13:04:16 -07:00
commit 1b60743303
274 changed files with 25866 additions and 0 deletions

View file

@ -0,0 +1,43 @@
// Decompiled with JetBrains decompiler
// Type: SEGATools.Binary.BinaryPatch
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: D631183F-57B1-40A1-B502-5364D288307A
// Assembly location: SEGATools.dll
using System;
using System.Security.Cryptography;
namespace SEGATools.Binary
{
public class BinaryPatch
{
private static readonly System.Security.Cryptography.HashAlgorithm HashAlgorithm = (System.Security.Cryptography.HashAlgorithm) SHA1.Create();
public long Offset { get; private set; }
public byte[] Data { get; private set; }
public string Hash { get; private set; }
internal BinaryPatch(long offset, byte[] data)
{
this.Offset = offset;
this.Data = data;
this.Hash = BitConverter.ToString(BinaryPatch.HashAlgorithm.ComputeHash(data));
}
public BinaryPatch Translate(long OffsetDelta) => new BinaryPatch(this.Offset + OffsetDelta, this.Data);
public override string ToString() => string.Format("BinaryPatch [Offset=0x{0:X}, Hash=0x{1}]", (object) this.Offset, (object) this.Hash);
public override int GetHashCode() => 1 + 17 * this.Offset.GetHashCode() + 31 * this.Hash.GetHashCode();
public override bool Equals(object obj)
{
if (obj == null || this.GetType() != obj.GetType())
return false;
BinaryPatch binaryPatch = (BinaryPatch) obj;
return this.Offset == binaryPatch.Offset && this.Hash.Equals(binaryPatch.Hash);
}
}
}

View file

@ -0,0 +1,37 @@
// Decompiled with JetBrains decompiler
// Type: SEGATools.Binary.BinaryPatcher
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: D631183F-57B1-40A1-B502-5364D288307A
// Assembly location: SEGATools.dll
using SEGATools.UserProcess;
using System.ComponentModel;
using System.IO;
namespace SEGATools.Binary
{
public class BinaryPatcher : UserProcessBase
{
public BinaryPatcher()
{
}
public BinaryPatcher(IContainer container)
: base(container)
{
}
public void ApplyPatch(System.IO.Stream stream, BinaryPatch Patch)
{
UserProcessBase.logger.DebugFormat("Applying {0}", (object) Patch);
stream.Seek(Patch.Offset, SeekOrigin.Begin);
stream.Write(Patch.Data, 0, Patch.Data.Length);
}
public void ApplyPatches(System.IO.Stream stream, BinaryPatch[] Patches)
{
foreach (BinaryPatch patch in Patches)
this.ApplyPatch(stream, patch);
}
}
}

View file

@ -0,0 +1,170 @@
// Decompiled with JetBrains decompiler
// Type: SEGATools.Binary.InitialProgramPatches
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: D631183F-57B1-40A1-B502-5364D288307A
// Assembly location: SEGATools.dll
using ImageReader.DiscSectors;
namespace SEGATools.Binary
{
public class InitialProgramPatches
{
private static int IP0000_REPEATED_TIME = 16;
public static BinaryPatch[] RegionFreePatchesForTrack1
{
get
{
BinaryPatch[] binaryPatchArray = new BinaryPatch[InitialProgramPatches.IP0000_REPEATED_TIME];
for (int index = 0; index < binaryPatchArray.Length; ++index)
binaryPatchArray[index] = InitialProgramPatches.RegionFreeFlagsPatch.Translate((long) (index * DiscSectorCommon.LogicalSectorSize));
return binaryPatchArray;
}
}
public static BinaryPatch[] RegionFreePatchesForTrack3 => new BinaryPatch[4]
{
InitialProgramPatches.RegionFreeFlagsPatch,
InitialProgramPatches.RegionJapanAreaProtectionSymbolsPatch,
InitialProgramPatches.RegionUsaAreaProtectionSymbolsPatch,
InitialProgramPatches.RegionEuropeAreaProtectionSymbolsPatch
};
public static BinaryPatch[] VGAFlagPatchesForTrack1
{
get
{
BinaryPatch[] binaryPatchArray = new BinaryPatch[InitialProgramPatches.IP0000_REPEATED_TIME];
for (int index = 0; index < binaryPatchArray.Length; ++index)
binaryPatchArray[index] = InitialProgramPatches.VGAFlagPatch.Translate((long) (index * DiscSectorCommon.LogicalSectorSize));
return binaryPatchArray;
}
}
public static BinaryPatch[] VGAFlagPatchesForTrack3 => new BinaryPatch[1]
{
InitialProgramPatches.VGAFlagPatch
};
public static BinaryPatch VGAFlagPatch => new BinaryPatch(61L, new byte[1]
{
(byte) 49
});
public static BinaryPatch RegionFreeFlagsPatch => new BinaryPatch(48L, new byte[3]
{
(byte) 74,
(byte) 85,
(byte) 69
});
public static BinaryPatch RegionJapanAreaProtectionSymbolsPatch => new BinaryPatch(14080L, new byte[32]
{
(byte) 14,
(byte) 160,
(byte) 9,
(byte) 0,
(byte) 70,
(byte) 111,
(byte) 114,
(byte) 32,
(byte) 74,
(byte) 65,
(byte) 80,
(byte) 65,
(byte) 78,
(byte) 44,
(byte) 84,
(byte) 65,
(byte) 73,
(byte) 87,
(byte) 65,
(byte) 78,
(byte) 44,
(byte) 80,
(byte) 72,
(byte) 73,
(byte) 76,
(byte) 73,
(byte) 80,
(byte) 73,
(byte) 78,
(byte) 69,
(byte) 83,
(byte) 46
});
public static BinaryPatch RegionUsaAreaProtectionSymbolsPatch => new BinaryPatch(14112L, new byte[32]
{
(byte) 14,
(byte) 160,
(byte) 9,
(byte) 0,
(byte) 70,
(byte) 111,
(byte) 114,
(byte) 32,
(byte) 85,
(byte) 83,
(byte) 65,
(byte) 32,
(byte) 97,
(byte) 110,
(byte) 100,
(byte) 32,
(byte) 67,
(byte) 65,
(byte) 78,
(byte) 65,
(byte) 68,
(byte) 65,
(byte) 46,
(byte) 32,
(byte) 32,
(byte) 32,
(byte) 32,
(byte) 32,
(byte) 32,
(byte) 32,
(byte) 32,
(byte) 32
});
public static BinaryPatch RegionEuropeAreaProtectionSymbolsPatch => new BinaryPatch(14144L, new byte[32]
{
(byte) 14,
(byte) 160,
(byte) 9,
(byte) 0,
(byte) 70,
(byte) 111,
(byte) 114,
(byte) 32,
(byte) 69,
(byte) 85,
(byte) 82,
(byte) 79,
(byte) 80,
(byte) 69,
(byte) 46,
(byte) 32,
(byte) 32,
(byte) 32,
(byte) 32,
(byte) 32,
(byte) 32,
(byte) 32,
(byte) 32,
(byte) 32,
(byte) 32,
(byte) 32,
(byte) 32,
(byte) 32,
(byte) 32,
(byte) 32,
(byte) 32,
(byte) 32
});
}
}

View file

@ -0,0 +1,59 @@
// Decompiled with JetBrains decompiler
// Type: SEGATools.Binary.SEGALibrary
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: D631183F-57B1-40A1-B502-5364D288307A
// Assembly location: SEGATools.dll
using System;
namespace SEGATools.Binary
{
public class SEGALibrary
{
public static readonly SEGALibrary AIP_103 = new SEGALibrary("AIP", new SEGALibraryVersion("1", "03"));
public static readonly SEGALibrary AIPf_105 = new SEGALibrary("AIPf", new SEGALibraryVersion("1", "05"));
public static readonly SEGALibrary SYTMR_053 = new SEGALibrary("syTmr", new SEGALibraryVersion("0", "53"));
public static readonly SEGALibrary FMMNG_103 = new SEGALibrary("fmMng", new SEGALibraryVersion("1", "03"));
public string Name { get; private set; }
public SEGALibraryVersion Version { get; private set; }
public DateTime BuildDate { get; private set; }
public SEGALibraryType GetLibraryType() => SEGALibrary.GetTypeFromName(this.Name);
public SEGALibrary(string Name, SEGALibraryVersion Version)
: this(Name, Version, new DateTime())
{
}
public SEGALibrary(string Name, SEGALibraryVersion Version, DateTime BuildOn)
{
this.Name = Name;
this.Version = Version;
this.BuildDate = BuildOn;
}
public override string ToString() => string.Format("[{0} v{1} build: {2}]", (object) this.Name, (object) this.Version, (object) this.BuildDate);
public override bool Equals(object obj)
{
if (obj == null || this.GetType() != obj.GetType())
return false;
SEGALibrary segaLibrary = (SEGALibrary) obj;
return this.GetLibraryType() == segaLibrary.GetLibraryType() && this.Version.Equals((object) segaLibrary.Version);
}
public override int GetHashCode() => 1 + 17 * this.Name.GetHashCode() + 31 * this.Version.GetHashCode();
private static SEGALibraryType GetTypeFromName(string Name)
{
if (SEGALibrary.AIP_103.Name.Equals(Name, StringComparison.InvariantCultureIgnoreCase) || SEGALibrary.AIPf_105.Name.Equals(Name, StringComparison.InvariantCultureIgnoreCase))
return SEGALibraryType.AIP;
if (SEGALibrary.SYTMR_053.Name.Equals(Name, StringComparison.InvariantCultureIgnoreCase))
return SEGALibraryType.SYS_TIMER;
return SEGALibrary.FMMNG_103.Name.Equals(Name, StringComparison.InvariantCultureIgnoreCase) ? SEGALibraryType.FLASH_MEMORY_MANAGER : SEGALibraryType.UNKNOWN;
}
}
}

View file

@ -0,0 +1,16 @@
// Decompiled with JetBrains decompiler
// Type: SEGATools.Binary.SEGALibraryType
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: D631183F-57B1-40A1-B502-5364D288307A
// Assembly location: SEGATools.dll
namespace SEGATools.Binary
{
public enum SEGALibraryType
{
UNKNOWN,
AIP,
SYS_TIMER,
FLASH_MEMORY_MANAGER,
}
}

View file

@ -0,0 +1,35 @@
// Decompiled with JetBrains decompiler
// Type: SEGATools.Binary.SEGALibraryVersion
// Assembly: SEGATools, Version=1.0.3.0, Culture=neutral, PublicKeyToken=611be24fdeb07e08
// MVID: D631183F-57B1-40A1-B502-5364D288307A
// Assembly location: SEGATools.dll
using System;
namespace SEGATools.Binary
{
public class SEGALibraryVersion : IComparable<SEGALibraryVersion>
{
public string Major { get; private set; }
public string Minor { get; private set; }
public SEGALibraryVersion(string major, string minor)
{
this.Major = major;
this.Minor = minor;
}
public override bool Equals(object obj) => obj != null && this.GetType() == obj.GetType() && this.CompareTo((SEGALibraryVersion) obj) == 0;
public override string ToString() => string.Format("{0}.{1}", (object) this.Major, (object) this.Minor);
public override int GetHashCode() => 1 + 17 * this.Major.GetHashCode() + 31 * this.Minor.GetHashCode();
public int CompareTo(SEGALibraryVersion other)
{
int num = this.Major.CompareTo(other.Major);
return num != 0 ? num : this.Minor.CompareTo(other.Minor);
}
}
}