From 9388afd54fdc6cd2b873ef9370b43e16de95a247 Mon Sep 17 00:00:00 2001 From: morkt Date: Tue, 16 Jan 2018 11:56:01 +0400 Subject: [PATCH] (Legacy): certain formats enabled in debug build only. --- Legacy/CocktailSoft/ArcPAK.cs | 4 ++ Legacy/EbgSystem/ArcBIN.cs | 2 + Legacy/Factor/ArcRES.cs | 2 + Legacy/Nabe/ImageYPF.cs | 2 + Legacy/Nekotaro/ArcNSC.cs | 2 + Legacy/PlanTech/ArcPAC.cs | 63 +++++++++++++++++ Legacy/PlanTech/ImagePAC.cs | 80 ++++++++++++++++++++++ Legacy/ShapeShifter/ArcBND.cs | 2 + Legacy/Uran/ArcNCL.cs | 2 + Legacy/Weapon/ArcDAT.cs | 125 ++++++++++++++++++++++++++++++++++ Legacy/Weapon/ArcVoice.cs | 78 +++++++++++++++++++++ Legacy/WestGate/ArcUCA.cs | 2 + Legacy/WestGate/ArcUSF.cs | 2 + Legacy/WestGate/ArcUWF.cs | 2 + 14 files changed, 368 insertions(+) create mode 100644 Legacy/PlanTech/ArcPAC.cs create mode 100644 Legacy/PlanTech/ImagePAC.cs create mode 100644 Legacy/Weapon/ArcDAT.cs create mode 100644 Legacy/Weapon/ArcVoice.cs diff --git a/Legacy/CocktailSoft/ArcPAK.cs b/Legacy/CocktailSoft/ArcPAK.cs index 37ce4eda..fdf67123 100644 --- a/Legacy/CocktailSoft/ArcPAK.cs +++ b/Legacy/CocktailSoft/ArcPAK.cs @@ -44,6 +44,10 @@ namespace GameRes.Formats.Cocktail public override bool IsHierarchic { get { return false; } } public override bool CanWrite { get { return false; } } +// static readonly uint[] KnownKeyCode = { 0x385AB4BA, 0x52CCCF4E }; +// static readonly uint[] KnownKeyCode = { 0x33C074B5, 0xB6744357 }; + static readonly uint[] KnownKeyCode = { 0xBBB64423, 0x4D765A33 }; + public override ArcFile TryOpen (ArcView file) { int count = file.View.ReadInt32 (4); diff --git a/Legacy/EbgSystem/ArcBIN.cs b/Legacy/EbgSystem/ArcBIN.cs index dbe010a0..bc97f48a 100644 --- a/Legacy/EbgSystem/ArcBIN.cs +++ b/Legacy/EbgSystem/ArcBIN.cs @@ -29,7 +29,9 @@ using System.Windows.Media; namespace GameRes.Formats.EbgSystem { +#if DEBUG [Export(typeof(ArchiveFormat))] +#endif public class BinOpener : ArchiveFormat { public override string Tag { get { return "BIN/EBG_SYSTEM"; } } diff --git a/Legacy/Factor/ArcRES.cs b/Legacy/Factor/ArcRES.cs index 3a80584f..c47419e1 100644 --- a/Legacy/Factor/ArcRES.cs +++ b/Legacy/Factor/ArcRES.cs @@ -31,7 +31,9 @@ using System.Text.RegularExpressions; namespace GameRes.Formats.Factor { +#if DEBUG [Export(typeof(ArchiveFormat))] +#endif public class PackOpener : ArchiveFormat { public override string Tag { get { return "PACK/FACTOR"; } } diff --git a/Legacy/Nabe/ImageYPF.cs b/Legacy/Nabe/ImageYPF.cs index 2addcc6a..ceac8436 100644 --- a/Legacy/Nabe/ImageYPF.cs +++ b/Legacy/Nabe/ImageYPF.cs @@ -29,7 +29,9 @@ using System.Windows.Media; namespace GameRes.Formats.Nabe { +#if DEBUG [Export(typeof(ImageFormat))] +#endif public class YpfFormat : ImageFormat { public override string Tag { get { return "YPF/NABE"; } } diff --git a/Legacy/Nekotaro/ArcNSC.cs b/Legacy/Nekotaro/ArcNSC.cs index 51fc02a0..e05065b5 100644 --- a/Legacy/Nekotaro/ArcNSC.cs +++ b/Legacy/Nekotaro/ArcNSC.cs @@ -27,6 +27,8 @@ using System.Collections.Generic; using System.ComponentModel.Composition; using System.IO; +// [000630][STONE HEADS] Sei Cosplay Gakuen ~Game Bunkou~ + namespace GameRes.Formats.Nekotaro { [Export(typeof(ArchiveFormat))] diff --git a/Legacy/PlanTech/ArcPAC.cs b/Legacy/PlanTech/ArcPAC.cs new file mode 100644 index 00000000..21374276 --- /dev/null +++ b/Legacy/PlanTech/ArcPAC.cs @@ -0,0 +1,63 @@ +//! \file ArcPAC.cs +//! \date 2018 Jan 03 +//! \brief PLANTECH bitmap packages. +// +// Copyright (C) 2018 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.PlanTech +{ +#if DEBUG + [Export(typeof(ArchiveFormat))] +#endif + public class PacOpener : ArchiveFormat + { + public override string Tag { get { return "PAC/PLANTECH"; } } + public override string Description { get { return "PLANTECH engine bitmap package"; } } + public override uint Signature { get { return 0; } } + public override bool IsHierarchic { get { return false; } } + public override bool CanWrite { get { return false; } } + + public override ArcFile TryOpen (ArcView file) + { + if (file.View.ReadInt32 (0) != 0) + return null; + if (!file.View.AsciiEqual (8, "BM")) + return null; + if (file.View.ReadUInt32 (4) != file.View.ReadUInt32 (10)) + return null; + + var dir = new List (1); + var entry = new Entry { + Name = Path.GetFileNameWithoutExtension (file.Name) + ".BMP", + Type = "image", + Offset = 8, + Size = (uint)(file.MaxOffset - 8), + }; + dir.Add (entry); + return new ArcFile (file, this, dir); + } + } +} diff --git a/Legacy/PlanTech/ImagePAC.cs b/Legacy/PlanTech/ImagePAC.cs new file mode 100644 index 00000000..02ce04a3 --- /dev/null +++ b/Legacy/PlanTech/ImagePAC.cs @@ -0,0 +1,80 @@ +//! \file ImagePAC.cs +//! \date 2018 Jan 03 +//! \brief PLANTECH bitmap packages. +// +// Copyright (C) 2018 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.ComponentModel.Composition; +using System.IO; +using System.Windows.Media; + +namespace GameRes.Formats.PlanTech +{ +#if DEBUG + [Export(typeof(ImageFormat))] +#endif + public class PacFormat : ImageFormat + { + public override string Tag { get { return "PAC/PLANTECH"; } } + public override string Description { get { return "PLANTECH engine bitmap package"; } } + public override uint Signature { get { return 0; } } + + public override ImageMetaData ReadMetaData (IBinaryStream file) + { + if (file.Signature != 0) + return null; + var header = file.ReadHeader (14); + if (!header.AsciiEqual (8, "BM")) + return null; + if (header.ToUInt32 (4) != header.ToUInt32 (10)) + return null; + using (var region = new StreamRegion (file.AsStream, 8, true)) + using (var bmp = new BinaryStream (region, file.Name)) + return Bmp.ReadMetaData (bmp); + } + + public override ImageData Read (IBinaryStream file, ImageMetaData info) + { + var meta = (BmpMetaData)info; + file.Position = 8 + meta.ImageOffset; + int stride = (((int)info.Width * info.BPP / 8) + 3) & ~3; + var pixels = file.ReadBytes (stride * (int)info.Height); + PixelFormat format; + if (24 == info.BPP) + format = PixelFormats.Bgr24; + else if (32 == info.BPP) + format = PixelFormats.Bgr32; + else if (16 == info.BPP) + format = PixelFormats.Bgr565; + else if (8 == info.BPP) + format = PixelFormats.Gray8; + else + throw new InvalidFormatException(); + return ImageData.Create (info, format, null, pixels, stride); + } + + public override void Write (Stream file, ImageData image) + { + throw new System.NotImplementedException ("PacFormat.Write not implemented"); + } + } +} diff --git a/Legacy/ShapeShifter/ArcBND.cs b/Legacy/ShapeShifter/ArcBND.cs index 62f13310..55a94afe 100644 --- a/Legacy/ShapeShifter/ArcBND.cs +++ b/Legacy/ShapeShifter/ArcBND.cs @@ -31,7 +31,9 @@ using GameRes.Utility; namespace GameRes.Formats.ShapeShifter { +#if DEBUG [Export(typeof(ArchiveFormat))] +#endif public class BndOpener : ArchiveFormat { public override string Tag { get { return "BND"; } } diff --git a/Legacy/Uran/ArcNCL.cs b/Legacy/Uran/ArcNCL.cs index d04894fd..d3f9006e 100644 --- a/Legacy/Uran/ArcNCL.cs +++ b/Legacy/Uran/ArcNCL.cs @@ -36,7 +36,9 @@ namespace GameRes.Formats.Uran public byte Method; } +#if DEBUG [Export(typeof(ArchiveFormat))] +#endif public class NclOpener : ArchiveFormat { public override string Tag { get { return "NCL"; } } diff --git a/Legacy/Weapon/ArcDAT.cs b/Legacy/Weapon/ArcDAT.cs new file mode 100644 index 00000000..715e9cee --- /dev/null +++ b/Legacy/Weapon/ArcDAT.cs @@ -0,0 +1,125 @@ +//! \file ArcDAT.cs +//! \date 2018 Jan 04 +//! \brief Weapon event CG archives. +// +// Copyright (C) 2018 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.Windows.Media; + +namespace GameRes.Formats.Weapon +{ + internal class CgEntry : Entry + { + public uint Height; + } + +#if DEBUG + [Export(typeof(ArchiveFormat))] +#endif + public class DatOpener : ArchiveFormat + { + public override string Tag { get { return "DAT/WEAPON"; } } + public override string Description { get { return "Weapon resource archive"; } } + public override uint Signature { get { return 0; } } + public override bool IsHierarchic { get { return false; } } + public override bool CanWrite { get { return false; } } + + const uint DefaultWidth = 800; + + public override ArcFile TryOpen (ArcView file) + { + var arc_name = Path.GetFileName (file.Name); + uint[] height_table; + if (!KnownFileTables.TryGetValue (arc_name, out height_table)) + return null; + uint stride = DefaultWidth * 2; + uint offset = 0; + var base_name = Path.GetFileNameWithoutExtension (arc_name); + var dir = new List (height_table.Length); + for (int i = 0; i < height_table.Length; ++i) + { + var name = string.Format ("{0}#{1:D4}", base_name, i); + var entry = new CgEntry { + Name = name, + Type = "image", + Offset = offset, + Size = height_table[i] * stride, + Height = height_table[i], + }; + if (!entry.CheckPlacement (file.MaxOffset)) + return null; + dir.Add (entry); + offset += entry.Size; + } + return new ArcFile (file, this, dir); + } + + public override IImageDecoder OpenImage (ArcFile arc, Entry entry) + { + var cgent = (CgEntry)entry; + var input = arc.File.CreateStream (entry.Offset, entry.Size); + var info = new ImageMetaData { Width = DefaultWidth, Height = cgent.Height, BPP = 16 }; + return new CgDecoder (input, info); + } + + static readonly Dictionary KnownFileTables = new Dictionary (StringComparer.InvariantCultureIgnoreCase) { + { "eventcg.dat", + new uint[] { + 600, 600, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, + 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, + 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, + 600, 600, 600, 600, 600, 1200, 600, 600, 600, 1200, 600, 600, 600, 600, 600, 600, + } + }, + { "buy.dat", + new uint[] { + 900, 34 + } + }, + }; + } + + internal class CgDecoder : BinaryImageDecoder + { + public CgDecoder (IBinaryStream input, ImageMetaData info) : base (input, info) + { + } + + protected override ImageData GetImageData () + { + int stride = (int)Info.Width * 2; + var pixels = m_input.ReadBytes (stride * (int)Info.Height); + for (int i = 0; i < pixels.Length; i += 2) + { + int hi = pixels[i] << 2 | (pixels[i+1] & 3); + int lo = pixels[i+1] >> 2 | (pixels[i] & ~0x1F); + pixels[i] = (byte)lo; + pixels[i+1] = (byte)hi; + } + return ImageData.Create (Info, PixelFormats.Bgr555, null, pixels, stride); + } + } +} diff --git a/Legacy/Weapon/ArcVoice.cs b/Legacy/Weapon/ArcVoice.cs new file mode 100644 index 00000000..ff97dc48 --- /dev/null +++ b/Legacy/Weapon/ArcVoice.cs @@ -0,0 +1,78 @@ +//! \file ArcVoice.cs +//! \date 2018 Jan 04 +//! \brief Weapon audio archive. +// +// Copyright (C) 2018 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; + +namespace GameRes.Formats.Weapon +{ +#if DEBUG + [Export(typeof(ArchiveFormat))] +#endif + public class VoiceOpener : ArchiveFormat + { + public override string Tag { get { return "DAT/W/VOICE"; } } + public override string Description { get { return "Weapon audio archive"; } } + public override uint Signature { get { return 0; } } + public override bool IsHierarchic { get { return false; } } + public override bool CanWrite { get { return false; } } + + public override ArcFile TryOpen (ArcView file) + { + int count = file.View.ReadInt32 (0); + if (!IsSaneCount (count)) + return null; + uint index_size = (uint)count * 4 + 8; + if (index_size > file.View.Reserve (0, index_size)) + return null; + if (file.View.ReadUInt32 (index_size-4) != file.MaxOffset) + return null; + + uint index_offset = 4; + uint offset = file.View.ReadUInt32 (index_offset); + if (offset < index_size) + return null; + var base_name = Path.GetFileNameWithoutExtension (file.Name); + var dir = new List (count); + for (int i = 0; i < count; ++i) + { + index_offset += 4; + var entry = new Entry { + Name = string.Format ("{0}#{1:D4}.wav", base_name, i), + Type = "audio", + Offset = offset, + }; + offset = file.View.ReadUInt32 (index_offset); + entry.Size = (uint)(offset - entry.Offset); + if (!entry.CheckPlacement (file.MaxOffset)) + return null; + dir.Add (entry); + } + return new ArcFile (file, this, dir); + } + } +} diff --git a/Legacy/WestGate/ArcUCA.cs b/Legacy/WestGate/ArcUCA.cs index 35fff7c9..c1b1ac7c 100644 --- a/Legacy/WestGate/ArcUCA.cs +++ b/Legacy/WestGate/ArcUCA.cs @@ -28,7 +28,9 @@ using System.ComponentModel.Composition; namespace GameRes.Formats.WestGate { +#if DEBUG [Export(typeof(ArchiveFormat))] +#endif public class UcaOpener : ArchiveFormat { public override string Tag { get { return "UCA"; } } diff --git a/Legacy/WestGate/ArcUSF.cs b/Legacy/WestGate/ArcUSF.cs index 73578987..1f76ac57 100644 --- a/Legacy/WestGate/ArcUSF.cs +++ b/Legacy/WestGate/ArcUSF.cs @@ -28,7 +28,9 @@ using System.ComponentModel.Composition; namespace GameRes.Formats.WestGate { +#if DEBUG [Export(typeof(ArchiveFormat))] +#endif public class UsfOpener : ArchiveFormat { public override string Tag { get { return "USF"; } } diff --git a/Legacy/WestGate/ArcUWF.cs b/Legacy/WestGate/ArcUWF.cs index c40100f6..41a5a2f9 100644 --- a/Legacy/WestGate/ArcUWF.cs +++ b/Legacy/WestGate/ArcUWF.cs @@ -29,7 +29,9 @@ using System.IO; namespace GameRes.Formats.WestGate { +#if DEBUG [Export(typeof(ArchiveFormat))] +#endif public class UwfOpener : ArchiveFormat { public override string Tag { get { return "UWF"; } }