From 08d0494a04ce10010b016aa88f172f9b902d9e7d Mon Sep 17 00:00:00 2001 From: morkt Date: Sun, 5 Feb 2017 21:08:52 +0400 Subject: [PATCH] implemented cromwell archives. --- ArcFormats/ArcFormats.csproj | 1 + ArcFormats/Cromwell/ArcPAK.cs | 124 ++++++++++++++++++++++++++++++++++ supported.html | 8 +++ 3 files changed, 133 insertions(+) create mode 100644 ArcFormats/Cromwell/ArcPAK.cs diff --git a/ArcFormats/ArcFormats.csproj b/ArcFormats/ArcFormats.csproj index 3d2d73f8..5a7e7ec1 100644 --- a/ArcFormats/ArcFormats.csproj +++ b/ArcFormats/ArcFormats.csproj @@ -103,6 +103,7 @@ + diff --git a/ArcFormats/Cromwell/ArcPAK.cs b/ArcFormats/Cromwell/ArcPAK.cs new file mode 100644 index 00000000..8cf546b0 --- /dev/null +++ b/ArcFormats/Cromwell/ArcPAK.cs @@ -0,0 +1,124 @@ +//! \file ArcPAK.cs +//! \date Sun Feb 05 13:07:40 2017 +//! \brief cromwell graphic resource archive. +// +// Copyright (C) 2017 by morkt +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// + +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.IO; +using GameRes.Compression; + +namespace GameRes.Formats.Cromwell +{ + [Export(typeof(ArchiveFormat))] + public class GraphicPakOpener : ArchiveFormat + { + public override string Tag { get { return "PAK/cromwell"; } } + public override string Description { get { return "cromwell graphic resource archive"; } } + public override uint Signature { get { return 0x70617247; } } // 'Graphic PackData' + public override bool IsHierarchic { get { return false; } } + public override bool CanWrite { get { return false; } } + + public override ArcFile TryOpen (ArcView file) + { + if (!file.View.AsciiEqual (4, "hic PackData")) + return null; + int count = file.View.ReadInt32 (0x10); + if (!IsSaneCount (count)) + return null; + + uint index_offset = 0x14; + var dir = new List (count); + for (int i = 0; i < count; ++i) + { + var name = file.View.ReadString (index_offset, 0xC); + if (string.IsNullOrWhiteSpace (name)) + return null; + index_offset += 0xC; + var entry = FormatCatalog.Instance.Create (name); + entry.Offset = file.View.ReadUInt32 (index_offset); + if (entry.Offset >= file.MaxOffset) + return null; + entry.UnpackedSize = file.View.ReadUInt32 (index_offset+4); + entry.IsPacked = true; + dir.Add (entry); + index_offset += 8; + } + for (int i = 0; i < count; ++i) + { + long next_offset = i+1 < count ? dir[i+1].Offset : file.MaxOffset; + dir[i].Size = (uint)(next_offset - dir[i].Offset); + } + return new ArcFile (file, this, dir); + } + + public override Stream OpenEntry (ArcFile arc, Entry entry) + { + var input = arc.File.CreateStream (entry.Offset, entry.Size); + return new ZLibStream (input, CompressionMode.Decompress); + } + } + + [Export(typeof(ArchiveFormat))] + public class OpkOpener : ArchiveFormat + { + public override string Tag { get { return "OPK"; } } + public override string Description { get { return "cromwell audio resource archive"; } } + public override uint Signature { get { return 0x63696F56; } } // 'VoiceOggPackFile' + public override bool IsHierarchic { get { return false; } } + public override bool CanWrite { get { return false; } } + + public override ArcFile TryOpen (ArcView file) + { + if (!file.View.AsciiEqual (4, "eOggPackFile")) + return null; + int count = file.View.ReadInt32 (0x10); + if (!IsSaneCount (count)) + return null; + + var base_name = Path.GetFileNameWithoutExtension (file.Name); + using (var input = file.CreateStream()) + { + input.Position = 0x14; + var dir = new List (count); + uint next_offset = input.ReadUInt32(); + for (int i = 0; i < count; ++i) + { + var entry = new Entry { Type = "audio" }; + entry.Offset = next_offset; + next_offset = input.ReadUInt32(); + entry.Size = (uint)(next_offset - entry.Offset); + if (!entry.CheckPlacement (file.MaxOffset)) + return null; + dir.Add (entry); + } + input.Position = next_offset; + foreach (var entry in dir) + { + entry.Name = input.ReadCString (8) + ".ogg"; + } + return new ArcFile (file, this, dir); + } + } + } +} diff --git a/supported.html b/supported.html index dbdb2276..440997af 100644 --- a/supported.html +++ b/supported.html @@ -152,6 +152,7 @@ Tiny Dungeon ~Brave or Slave~
Ayase Ke no Onna ~Inka no Ketsumyaku~
Chokotto☆Vampire!
Clover Point
+Kindan ~Kimi wa Boku Dake no Maiden~
Setsuei
Tsuki to Mahou to Taiyo to
@@ -439,6 +440,8 @@ Touka Gettan
*.warWARC 1.7
WARC 1.5
WARC 1.4
WARC 1.3
WARC 1.2NoShiina Rio Ao no Juuai ShiinaRio v2.34
Aneiro ShiinaRio v2.49
+Bitch Nee-chan ga Seijun na Hazu ga Nai! ShiinaRio v2.50
+Bitch Shimai ga Seijun na Hazu ga Nai!! ShiinaRio v2.50
Can Fes! ~Itazura Majo to Naisho no Gakuensai~ ShiinaRio v2.47
Chikan Circle ShiinaRio v2.46
Chikan Circle 2 ShiinaRio v2.47
@@ -453,6 +456,7 @@ Draculius ShiinaRio v2.38
Enkaku Sousa 2.36 or 2.37
Gakushoku no Oba-san The Motion ShiinaRio v2.48
Gensou no Idea ~Oratorio Phantasm Historia~ShiinaRio v2.49
+Gibo to Oba ~Soshite Yuujin no Haha~ ShiinaRio v2.36
Gohoushi Nurse ~Mayonaka no Kyousei Call~ ShiinaRio v2.50
Hana no Kioku 1-2-3 ShiinaRio v2.10
Hana no Kioku 4-5-6 ShiinaRio v2.19
@@ -1413,6 +1417,10 @@ Ryoujoku Joshi Gakuen
*.wrcWVX0No *.wsmWSM1
WSM2
WSM3No *BCNo +*.pakGraphic PackDataNocromwell +Ikenie Reijou
+ +*.opkVoiceOggPackFileNo

1 Non-encrypted only