diff --git a/ArcFormats/ArcFormats.csproj b/ArcFormats/ArcFormats.csproj index 965b6bcf..3e101597 100644 --- a/ArcFormats/ArcFormats.csproj +++ b/ArcFormats/ArcFormats.csproj @@ -141,6 +141,8 @@ WidgetNCARC.xaml + + diff --git a/ArcFormats/Patisserie/ArcBIN.cs b/ArcFormats/Patisserie/ArcBIN.cs new file mode 100644 index 00000000..1749b020 --- /dev/null +++ b/ArcFormats/Patisserie/ArcBIN.cs @@ -0,0 +1,202 @@ +//! \file ArcBIN.cs +//! \date Thu Jul 21 21:10:31 2016 +//! \brief Patisserie resource archive. +// +// Copyright (C) 2016 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; +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.IO; +using System.Linq; +using GameRes.Compression; + +namespace GameRes.Formats.Patisserie +{ + [Export(typeof(ArchiveFormat))] + public class BinOpener : ArchiveFormat + { + public override string Tag { get { return "BIN/OZ"; } } + public override string Description { get { return "Patisserie resource archive"; } } + public override uint Signature { get { return 0x01005A4F; } } // 'OZ' + public override bool IsHierarchic { get { return false; } } + public override bool CanCreate { get { return false; } } + + public BinOpener () + { + Extensions = new string[] { "bin" }; + } + + public override ArcFile TryOpen (ArcView file) + { + if (!file.View.AsciiEqual (4, "OFST")) + return null; + int index_size = file.View.ReadInt32 (8); + int count = index_size / 4; + if (!IsSaneCount (count)) + return null; + var base_name = Path.GetFileNameWithoutExtension (file.Name); + string content_ext = "", content_type = ""; + if (base_name.EndsWith ("flac", StringComparison.InvariantCultureIgnoreCase)) + { + content_ext = "flac"; + content_type = "audio"; + base_name = base_name.Substring (0, base_name.Length-4); + } + else if (base_name.EndsWith ("ogg", StringComparison.InvariantCultureIgnoreCase)) + { + content_ext = "ogg"; + content_type = "audio"; + base_name = base_name.Substring (0, base_name.Length-3); + } + + var filenames = GetFileNames (VFS.GetDirectoryName (file.Name), base_name); + if (null == filenames) + filenames = new List (count); + for (int i = filenames.Count; i < count; ++i) + filenames.Add (string.Format ("{0}#{1:D5}", base_name, i)); + + uint index_offset = 0xC; + var dir = new List (count); + uint next_offset = file.View.ReadUInt32 (index_offset); + for (int i = 0; i < count; ++i) + { + index_offset += 4; + var entry = new PackedEntry { Name = filenames[i] }; + entry.Offset = next_offset; + next_offset = i+1 < count ? file.View.ReadUInt32 (index_offset) : (uint)file.MaxOffset; + entry.Size = next_offset - (uint)entry.Offset; + if (entry.Size > 0 && !entry.CheckPlacement (file.MaxOffset)) + return null; + if (!string.IsNullOrEmpty (content_type)) + { + entry.Type = content_type; + entry.Name = Path.ChangeExtension (entry.Name, content_ext); + } + dir.Add (entry); + } + foreach (PackedEntry entry in dir.Where (e => e.Size > 4)) + { + entry.IsPacked = file.View.AsciiEqual (entry.Offset, "DFLT"); + if (entry.IsPacked) + { + entry.Size = file.View.ReadUInt32 (entry.Offset+4); + entry.UnpackedSize = file.View.ReadUInt32 (entry.Offset+8); + entry.Offset += 12; + } + else if (file.View.AsciiEqual (entry.Offset, "DATA")) + { + entry.Size = file.View.ReadUInt32 (entry.Offset+4); + entry.UnpackedSize = entry.Size; + entry.Offset += 8; + if (string.IsNullOrEmpty (entry.Type)) + { + uint signature = file.View.ReadUInt32 (entry.Offset); + if (0x43614C66 == signature) // 'fLaC' + { + entry.Type = "audio"; + entry.Name = Path.ChangeExtension (entry.Name, "flac"); + } + else + { + var res = AutoEntry.DetectFileType (signature); + if (null != res) + { + entry.Type = res.Type; + var ext = res.Extensions.FirstOrDefault(); + if (!string.IsNullOrEmpty (ext)) + entry.Name = Path.ChangeExtension (entry.Name, ext); + } + } + } + } + } + return new ArcFile (file, this, dir); + } + + public override Stream OpenEntry (ArcFile arc, Entry entry) + { + var input = arc.File.CreateStream (entry.Offset, entry.Size); + var pent = entry as PackedEntry; + if (null == pent || !pent.IsPacked) + return input; + return new ZLibStream (input, CompressionMode.Decompress); + } + + IList GetArcNames (string lst_name) + { + return File.ReadAllLines (lst_name, Encodings.cp932); + } + + IList GetFileNames (string dir_name, string base_name) + { + var lists_lst_name = VFS.CombinePath (dir_name, "lists.lst"); + if (!VFS.FileExists (lists_lst_name)) + return null; + var arcs = GetArcNames (lists_lst_name); + var arc_no = arcs.IndexOf (base_name); + if (-1 == arc_no) + return null; + var lists_bin_name = VFS.CombinePath (dir_name, "lists.bin"); + using (var lists_bin = VFS.OpenView (lists_bin_name)) + return ReadFileNames (lists_bin, arc_no); + } + + IList ReadFileNames (ArcView index, int arc_no) + { + if (index.View.ReadUInt32 (0) != Signature) + return null; + if (!index.View.AsciiEqual (4, "OFST")) + return null; + int index_size = index.View.ReadInt32 (8); + int arc_count = index_size / 4; + if (arc_no >= arc_count) + return null; + uint index_offset = index.View.ReadUInt32 (0xC + arc_no * 4); + if (index_offset >= index.MaxOffset) + return null; + Stream input; + if (index.View.AsciiEqual (index_offset, "DFLT")) + { + uint packed_size = index.View.ReadUInt32 (index_offset+4); + input = index.CreateStream (index_offset+12, packed_size); + input = new ZLibStream (input, CompressionMode.Decompress); + } + else if (index.View.AsciiEqual (index_offset, "DATA")) + { + uint data_size = index.View.ReadUInt32 (index_offset+4); + input = index.CreateStream (index_offset+8, data_size); + } + else + return null; + using (input) + using (var reader = new StreamReader (input, Encodings.cp932)) + { + var list = new List(); + string line; + while ((line = reader.ReadLine()) != null) + list.Add (line.Trim()); + return list; + } + } + } +} diff --git a/ArcFormats/Patisserie/ArcRAW.cs b/ArcFormats/Patisserie/ArcRAW.cs new file mode 100644 index 00000000..1f717280 --- /dev/null +++ b/ArcFormats/Patisserie/ArcRAW.cs @@ -0,0 +1,88 @@ +//! \file ArcRAW.cs +//! \date Fri Jul 22 00:56:19 2016 +//! \brief Patisserie animation resource. +// +// Copyright (C) 2016 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; + +namespace GameRes.Formats.Patisserie +{ + [Export(typeof(ArchiveFormat))] + public class RawOpener : ArchiveFormat + { + public override string Tag { get { return "ABB/RAW"; } } + public override string Description { get { return "Patisserie animation resource"; } } + public override uint Signature { get { return 0x04574152; } } // 'RAW\x04' + public override bool IsHierarchic { get { return false; } } + public override bool CanCreate { get { return false; } } + + public RawOpener () + { + Extensions = new string[] { "raw" }; + } + + public override ArcFile TryOpen (ArcView file) + { + uint end = file.View.ReadUInt32 (4); + if (end > file.MaxOffset - 8) + return null; + end += 8; + uint current_offset = 8; + var dir = new List(); + int i = 0; + while (current_offset < end) + { + var entry = new Entry { + Name = string.Format (i.ToString ("D4")), + Type = "image", + Offset = current_offset, + }; + uint width = file.View.ReadUInt32 (current_offset+0xC); + uint height = file.View.ReadUInt32 (current_offset+0x10); + entry.Size = 0x14 + 4 * width * height; + if (!entry.CheckPlacement (file.MaxOffset)) + return null; + dir.Add (entry); + current_offset += entry.Size; + ++i; + } + return new ArcFile (file, this, dir); + } + + public override Stream OpenEntry (ArcFile arc, Entry entry) + { + var info = new ImageMetaData + { + OffsetX = arc.File.View.ReadInt32 (entry.Offset+4), + OffsetY = arc.File.View.ReadInt32(entry.Offset+8), + Width = arc.File.View.ReadUInt32(entry.Offset+0xC), + Height = arc.File.View.ReadUInt32(entry.Offset+0x10), + BPP = 32, + }; + var pixels = arc.File.View.ReadBytes (entry.Offset+0x14, entry.Size-0x14); + return TgaStream.Create (info, pixels); + } + } +} diff --git a/supported.html b/supported.html index 6ecca312..6e4c3063 100644 --- a/supported.html +++ b/supported.html @@ -169,6 +169,7 @@ Baldr Sky DiveX
Fossette ~Cafe au Le Ciel Bleu~
Jinki Extend Re:Vision
Maji de Watashi ni Koishinasai!
+Xross Scramble
*.grpGR3No *.pacPAC1NoRAGE @@ -209,6 +210,7 @@ Love Negotiator
Sekien no Inganock
Shikkoku no Sharnoth
Yami no Sen Ou ~Seijo Ojoku~
+Astelight series
*.lwgLGNo *.wcgWGqYes @@ -322,6 +324,7 @@ Genecracer Saki
Hazama no Tsuki
Hensai Keikaku
Himawari Oka Sougou Byouin e Youkoso
+Futari no Erika ~Osanajimi to Ima Kanojo to~
Inen no Yakata
Inran OL Sawatari Tokiko
Itsuwari no Kyoushitsu
@@ -382,6 +385,7 @@ Lovers Collection
Nachtmusik
Nachtmusik Another
Oto☆Puri
+Prawf Clwyd
Rakuen no Rukia ~Blood Moon Rising~
Samayou Mitama ni Yasuragi no Toki wo
Time Trouble ~Marie ni Kubikkake~
@@ -476,6 +480,7 @@ Inkou Haden Amatsu ~Hakudaku no Juin~
Magical Witch Academy
Medorei ~Okasareta Houkago~
Onna Kyoushi
+Ore to Kanojo wa Shuju na Kankei
Saishuu Chikan Densha
Serina
Ura Nyuugaku ~Ineki ni Nureta Kyoukasho~
@@ -588,6 +593,7 @@ Shinsetsu Ryouki no Ori
Gokudou no Hanayome
Inraku no Miko
Knight Carnival!
+Nise Kyoushi ~Seikatsu Shidou ADV~
Seal Princess
Zettai★Maou ~Boku no Mune-kyun Gakuen Saga~
@@ -631,6 +637,7 @@ Seinarukana -The Spirit of Eternity Sword 2-
*.ykcYKC001YesYuka Aozora no Mieru Oka
HoneyComing
+Hoshizora e Kakaru Hashi AA
PriministAr
SuGirly Wish
_summer
@@ -666,6 +673,7 @@ Soukai no Valkyria
Ashita wa Kitto, Haremasu you ni
Cross Quartz
Hyakki Yakou
+Mahou Senshi Extra Stage 2 ~Gakuen Kangoku~
Saikyou Goshujin-sama! -Mighty My Master-
Saiminjutsu Re
Wizard Links
@@ -810,7 +818,8 @@ Planet Dragon
*.gd+*.dll-NoXuse Eien no Aselia -The Spirit of Eternity Sword- -*.datDAF2NoDenSDK +*.datDAF1
DAF2NoDenSDK +Ayakashi
Ayakashi H
*.arcLINK3NoKaGuYa @@ -840,6 +849,7 @@ Unity Marriage ~Futari no Hanayome~
*.pgdGE
PGD3No *.npkNPK2NoNitro+ +Sonicomi
Tokyo Necro
*arcNoADVEngine @@ -863,6 +873,7 @@ Ase Nure Shoujo Misaki "Anata no Nioi de Icchau!"
D-spray Biyaku de Motemote Kachou Dairi Hosa
Hitomi no Rakuin ~Inbaku no Mesu Dorei~
Jokujima
+Saiin Haramase Keyword
*.grp-NoAnkh Mozu
@@ -939,12 +950,17 @@ Kara no Shoujo 2
data.NN
ArcNN.dat-NoCyberworks Cosplay Ecchi ~Layer Kana no Yuuutsu~
+Hanamaru! 2
Hime Kami 1/2
+In'youchuu Goku ~Ryoujoku Jigoku Taimaroku~
In'youchuu Rei ~Ryoujoku Shiro Taima Emaki~
Oshioki ~Gakuen Reijou Kousei Keikaku~
Ore Maou! ~Kudake Chitta Tamashii
Zoku Etsuraku no Tane
+*.binOZNoPatisserie +Ore no Tamanokoshi ni Notte Kure
+

1 Non-encrypted only