diff --git a/ArcFormats/ArcFormats.csproj b/ArcFormats/ArcFormats.csproj index c6047aab..39a54213 100644 --- a/ArcFormats/ArcFormats.csproj +++ b/ArcFormats/ArcFormats.csproj @@ -79,6 +79,7 @@ + @@ -124,6 +125,7 @@ CreateYPFWidget.xaml + @@ -132,6 +134,7 @@ + diff --git a/ArcFormats/ArcMnoViolet.cs b/ArcFormats/ArcMnoViolet.cs new file mode 100644 index 00000000..187a4a82 --- /dev/null +++ b/ArcFormats/ArcMnoViolet.cs @@ -0,0 +1,77 @@ +//! \file ArcMnoViolet.cs +//! \date Fri Apr 03 23:32:37 2015 +//! \brief M no Violet engine archives implementation. +// +// Copyright (C) 2015 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 GameRes.Utility; + +namespace GameRes.Formats.MnoViolet +{ + [Export(typeof(ArchiveFormat))] + public class DatOpener : ArchiveFormat + { + public override string Tag { get { return "MNV"; } } + public override string Description { get { return "M no Violet resource archive"; } } + public override uint Signature { get { return 0; } } + public override bool IsHierarchic { get { return true; } } + public override bool CanCreate { get { return false; } } + + public DatOpener () + { + Extensions = new string[] { "dat" }; + } + + public override ArcFile TryOpen (ArcView file) + { + int count = file.View.ReadInt32 (0); + if (count <= 0 || count > 0xfffff) + return null; + uint name_size = 100; + uint index_size = (uint)((name_size+8) * count); + if (index_size > file.View.Reserve (4, index_size)) + return null; + var dir = new List (count); + long index_offset = 4; + for (int i = 0; i < count; ++i) + { + string name = file.View.ReadString (index_offset, name_size); + if (0 == name.Length) + return null; + index_offset += name_size; + uint offset = file.View.ReadUInt32 (index_offset+4); + var entry = AutoEntry.Create (file, offset, name); + entry.Offset = offset; + entry.Size = file.View.ReadUInt32 (index_offset); + if (offset <= index_size || !entry.CheckPlacement (file.MaxOffset)) + return null; + dir.Add (entry); + index_offset += 8; + } + return new ArcFile (file, this, dir); + } + } +} diff --git a/ArcFormats/ImageMNV.cs b/ArcFormats/ImageMNV.cs new file mode 100644 index 00000000..b176247b --- /dev/null +++ b/ArcFormats/ImageMNV.cs @@ -0,0 +1,103 @@ +//! \file ImageMNV.cs +//! \date Sat Apr 04 00:33:34 2015 +//! \brief M no Violet engine images implementation. +// +// Copyright (C) 2015 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.ComponentModel.Composition; +using System.IO; +using System.Windows; +using System.Windows.Media; +using System.Windows.Media.Imaging; + +namespace GameRes.Formats.MnoViolet +{ + internal class GraMetaData : ImageMetaData + { + public int PackedSize; + public int UnpackedSize; + } + + [Export(typeof(ImageFormat))] + public class GraFormat : ImageFormat + { + public override string Tag { get { return "GRA"; } } + public override string Description { get { return "M no Violet image format"; } } + public override uint Signature { get { return 0x00617267; } } // 'gra' + + public GraFormat () + { + Signatures = new uint[] { 0x00617267, 0x0073616d }; // 'gra', 'mas' + } + + public override void Write (Stream file, ImageData image) + { + throw new NotImplementedException ("GraFormat.Write not implemented"); + } + + public override ImageMetaData ReadMetaData (Stream stream) + { + using (var input = new ArcView.Reader (stream)) + { + uint sign = input.ReadUInt32(); + uint width = input.ReadUInt32(); + uint height = input.ReadUInt32(); + int packed_size = input.ReadInt32(); + int data_size = input.ReadInt32(); + return new GraMetaData + { + Width = width, + Height = height, + PackedSize = packed_size, + UnpackedSize = data_size, + BPP = 0x617267 == sign ? 24 : 8, + }; + } + } + + public override ImageData Read (Stream stream, ImageMetaData info) + { + var meta = info as GraMetaData; + if (null == meta) + throw new ArgumentException ("GraFormat.Read should be supplied with GraMetaData", "info"); + + stream.Position = 0x14; + using (var reader = new LzssReader (stream, meta.PackedSize, meta.UnpackedSize)) + { + reader.Unpack(); + int stride = (int)info.Width*info.BPP/8; + var pixels = reader.Data; + PixelFormat format; + if (24 == info.BPP) + format = PixelFormats.Bgr24; + else + format = PixelFormats.Gray8; + var bitmap = BitmapSource.Create ((int)info.Width, (int)info.Height, 96, 96, + format, null, pixels, stride); + var flipped = new TransformedBitmap (bitmap, new ScaleTransform { ScaleY = -1 }); + flipped.Freeze(); + return new ImageData (flipped, info); + } + } + } +} diff --git a/ArcFormats/Properties/AssemblyInfo.cs b/ArcFormats/Properties/AssemblyInfo.cs index 7f261be6..56da56a8 100644 --- a/ArcFormats/Properties/AssemblyInfo.cs +++ b/ArcFormats/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion ("1.0.4.34")] -[assembly: AssemblyFileVersion ("1.0.4.34")] +[assembly: AssemblyVersion ("1.0.4.35")] +[assembly: AssemblyFileVersion ("1.0.4.35")] diff --git a/supported.html b/supported.html index e2aa62a0..a82ce55d 100644 --- a/supported.html +++ b/supported.html @@ -100,6 +100,8 @@ Swan Song
*.datNoneYesStudio e.go!Men at Work 2 *.mblNoneNoMarbleIkusa Otome Valkyrie *.prsYBNo +*.datNoneNoM no VioletNanase Ren +*gra
masNo

[1] Non-encrypted only