Skip to content

Commit

Permalink
Merge pull request #43 from hozuki/v0.7.7
Browse files Browse the repository at this point in the history
v0.7.7
  • Loading branch information
hozuki committed Dec 14, 2017
2 parents 2276a51 + e0616e7 commit b670060
Show file tree
Hide file tree
Showing 282 changed files with 321 additions and 14,790 deletions.
4 changes: 4 additions & 0 deletions Apps/AcbMaker/DereTore.Apps.AcbMaker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
Expand All @@ -30,6 +31,7 @@
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -39,6 +41,7 @@
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
Expand All @@ -48,6 +51,7 @@
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="System.Core" />
Expand Down
8 changes: 4 additions & 4 deletions Apps/AcbUnzip/DereTore.Apps.AcbUnzip.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>4</LangVersion>
<LangVersion>6</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
Expand All @@ -29,7 +29,7 @@
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>4</LangVersion>
<LangVersion>6</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
Expand All @@ -39,7 +39,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>4</LangVersion>
<LangVersion>6</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
Expand All @@ -49,7 +49,7 @@
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>4</LangVersion>
<LangVersion>6</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
Expand Down
35 changes: 27 additions & 8 deletions Apps/AcbUnzip/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using DereTore.Exchange.Archive.ACB;

Expand All @@ -13,21 +13,40 @@ internal static class Program {
var fileName = args[0];
var fileInfo = new FileInfo(fileName);

var fullDirPath = Path.Combine(fileInfo.DirectoryName ?? string.Empty, string.Format(DirTemplate, fileInfo.Name));
var fullDirPath = Path.Combine(fileInfo.DirectoryName, string.Format(DirTemplate, fileInfo.Name));
if (!Directory.Exists(fullDirPath)) {
Directory.CreateDirectory(fullDirPath);
}

using (var acb = AcbFile.FromFile(fileName)) {
var fileNames = acb.GetFileNames();
foreach (var s in fileNames) {
var archivedEntryNames = acb.GetFileNames();
for (var i = 0; i < archivedEntryNames.Length; ++i) {
var isCueNonEmpty = archivedEntryNames[i] != null;
var s = archivedEntryNames[i] ?? AcbFile.GetSymbolicFileNameFromCueId((uint)i);
var extractName = Path.Combine(fullDirPath, s);
using (var fs = new FileStream(extractName, FileMode.Create, FileAccess.Write)) {
using (var source = acb.OpenDataStream(s)) {
WriteFile(source, fs);
try {
using (var source = isCueNonEmpty ? acb.OpenDataStream(s) : acb.OpenDataStream((uint)i)) {
using (var fs = new FileStream(extractName, FileMode.Create, FileAccess.Write)) {
WriteFile(source, fs);
}
}
Console.WriteLine(s);
} catch (Exception ex) {
var origForeground = ConsoleColor.Gray;
try {
origForeground = Console.ForegroundColor;
} catch {
}
try {
Console.ForegroundColor = ConsoleColor.Red;
} catch {
}
Console.WriteLine(ex.Message);
try {
Console.ForegroundColor = origForeground;
} catch {
}
}
Console.WriteLine(s);
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions Apps/Hca2Wav/DereTore.Apps.Hca2Wav.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
Expand All @@ -31,6 +32,7 @@
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -40,6 +42,7 @@
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
Expand All @@ -49,6 +52,7 @@
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommandLine, Version=1.9.71.2, Culture=neutral, PublicKeyToken=de6f01bd326f8c32, processorArchitecture=MSIL">
Expand Down
23 changes: 13 additions & 10 deletions Apps/Hca2Wav/Options.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
using CommandLine;
using CommandLine;
using DereTore.Common.StarlightStage;
using DereTore.Exchange.Audio.HCA;

namespace DereTore.Apps.Hca2Wav {
public sealed class Options {

[Option('i', "in", Required = true)]
[ValueOption(0)]
public string InputFileName { get; set; } = string.Empty;

[Option('o', "out", Required = false)]
[Option('o', "out", HelpText = "Output file name", Required = false)]
public string OutputFileName { get; set; } = string.Empty;

[Option('a', "key1", Required = false)]
[Option('a', "key1", HelpText = "Key 1 (8 hex digits)", Required = false, DefaultValue = "f27e3b22")]
public string Key1 { get; set; } = CgssCipher.Key1.ToString("x8");

[Option('b', "key2", Required = false)]
[Option('b', "key2", HelpText = "Key 2 (8 hex digits)", Required = false, DefaultValue = "00003657")]
public string Key2 { get; set; } = CgssCipher.Key2.ToString("x8");

[Option("infinite", Required = false)]
[Option("infinite", HelpText = "Enables infinite loop", Required = false, DefaultValue = false)]
public bool InfiniteLoop { get; set; } = AudioParams.Default.InfiniteLoop;

[Option('l', "loop", Required = false)]
[Option('l', "loop", HelpText = "Number of simulated loops", Required = false, DefaultValue = 0u)]
public uint SimulatedLoopCount { get; set; } = AudioParams.Default.SimulatedLoopCount;

[Option('e', "header", Required = false)]
public bool OutputWaveHeader { get; set; } = true;
[Option('e', "no-header", HelpText = "Do not emit wave header", Required = false, DefaultValue = false)]
public bool NoWaveHeader { get; set; }

[Option('c', "cipher", Required = false)]
[Option("overrides-cipher", HelpText = "Overrides original cipher type", Required = false, DefaultValue = false)]
public bool OverridesCipherType { get; set; }

[Option('c', "cipher", HelpText = "Overridden cipher type", Required = false, DefaultValue = 0u)]
public uint OverriddenCipherType { get; set; }

}
Expand Down
29 changes: 22 additions & 7 deletions Apps/Hca2Wav/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Globalization;
using System.IO;
using DereTore.Common.StarlightStage;
Expand All @@ -10,8 +10,21 @@ internal static class Program {
private static int Main(string[] args) {
var options = new Options();
var succeeded = CommandLine.Parser.Default.ParseArguments(args, options);

if (string.IsNullOrWhiteSpace(options.InputFileName)) {
succeeded = false;
}

if (!succeeded) {
Console.WriteLine(HelpMessage);
var helpText = CommandLine.Text.HelpText.AutoBuild(options);
helpText.AddPreOptionsLine(" ");
helpText.AddPreOptionsLine("Usage: hca2wav <input HCA> [options]");
Console.Error.WriteLine(helpText);
return CommandLine.Parser.DefaultExitCodeFail;
}

if (!File.Exists(options.InputFileName)) {
Console.Error.WriteLine("File not found: {0}", options.InputFileName);
return CommandLine.Parser.DefaultExitCodeFail;
}

Expand All @@ -25,15 +38,15 @@ internal static class Program {
var formatProvider = new NumberFormatInfo();
if (!string.IsNullOrWhiteSpace(options.Key1)) {
if (!uint.TryParse(options.Key1, NumberStyles.HexNumber, formatProvider, out key1)) {
Console.WriteLine("ERROR: key 1 is of wrong format.");
Console.WriteLine("ERROR: key 1 is of wrong format. It should look like \"a1b2c3d4\".");
return CommandLine.Parser.DefaultExitCodeFail;
}
} else {
key1 = CgssCipher.Key1;
}
if (!string.IsNullOrWhiteSpace(options.Key2)) {
if (!uint.TryParse(options.Key2, NumberStyles.HexNumber, formatProvider, out key2)) {
Console.WriteLine("ERROR: key 2 is of wrong format.");
Console.WriteLine("ERROR: key 2 is of wrong format. It should look like \"a1b2c3d4\".");
return CommandLine.Parser.DefaultExitCodeFail;
}
} else {
Expand All @@ -45,10 +58,14 @@ internal static class Program {
var decodeParams = DecodeParams.CreateDefault();
decodeParams.Key1 = key1;
decodeParams.Key2 = key2;
if (options.OverridesCipherType) {
decodeParams.CipherTypeOverrideEnabled = true;
decodeParams.OverriddenCipherType = (CipherType)options.OverriddenCipherType;
}
var audioParams = AudioParams.CreateDefault();
audioParams.InfiniteLoop = options.InfiniteLoop;
audioParams.SimulatedLoopCount = options.SimulatedLoopCount;
audioParams.OutputWaveHeader = options.OutputWaveHeader;
audioParams.OutputWaveHeader = !options.NoWaveHeader;
using (var hcaStream = new HcaAudioStream(inputFileStream, decodeParams, audioParams)) {
var read = 1;
var dataBuffer = new byte[1024];
Expand All @@ -65,7 +82,5 @@ internal static class Program {
return 0;
}

private static readonly string HelpMessage = "Usage: hca2wav.exe -i <input HCA> [-o <output WAVE = <input HCA>.wav>] [-a <key 1>] [-b <key 2>] [-l <loop count>] [--infinite] [--header]";

}
}
4 changes: 4 additions & 0 deletions Apps/Hcacc/DereTore.Apps.Hcacc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
Expand All @@ -30,6 +31,7 @@
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -39,6 +41,7 @@
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
Expand All @@ -48,6 +51,7 @@
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="System.Core" />
Expand Down
4 changes: 4 additions & 0 deletions Apps/Hcaenc/DereTore.Apps.Hcaenc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
Expand All @@ -30,6 +31,7 @@
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -39,6 +41,7 @@
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
Expand All @@ -48,6 +51,7 @@
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="System.Core" />
Expand Down
4 changes: 4 additions & 0 deletions Apps/JacketCreator/DereTore.Apps.JacketCreator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
Expand All @@ -29,6 +30,7 @@
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -38,6 +40,7 @@
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
Expand All @@ -47,6 +50,7 @@
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommandLine, Version=1.9.71.2, Culture=neutral, PublicKeyToken=de6f01bd326f8c32, processorArchitecture=MSIL">
Expand Down
4 changes: 4 additions & 0 deletions Apps/LZ4/DereTore.Apps.LZ4.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
Expand All @@ -29,6 +30,7 @@
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -38,6 +40,7 @@
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
Expand All @@ -47,6 +50,7 @@
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<LangVersion>6</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand Down
Loading

0 comments on commit b670060

Please sign in to comment.