implemented "M no Violet" engine resources.

This commit is contained in:
morkt 2015-04-04 05:32:01 +04:00
parent 0ca1c7248f
commit 3e56c4dd8f
5 changed files with 187 additions and 2 deletions

View File

@ -79,6 +79,7 @@
<Compile Include="ArcMajiro.cs" />
<Compile Include="ArcMBL.cs" />
<Compile Include="ArcMGPK.cs" />
<Compile Include="ArcMnoViolet.cs" />
<Compile Include="ArcNEKO.cs" />
<Compile Include="ArcNexas.cs" />
<Compile Include="ArcNitro.cs" />
@ -124,6 +125,7 @@
<Compile Include="CreateYPFWidget.xaml.cs">
<DependentUpon>CreateYPFWidget.xaml</DependentUpon>
</Compile>
<Compile Include="ImageBGI.cs" />
<Compile Include="ImageBIP.cs" />
<Compile Include="ImageBMD.cs" />
<Compile Include="ImageBMZ.cs" />
@ -132,6 +134,7 @@
<Compile Include="ImageGCP.cs" />
<Compile Include="ImageHG3.cs" />
<Compile Include="ImageISG.cs" />
<Compile Include="ImageMNV.cs" />
<Compile Include="ImagePRS.cs" />
<Compile Include="ImageRCT.cs" />
<Compile Include="ImageTGF.cs" />

View File

@ -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<Entry> (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);
}
}
}

103
ArcFormats/ImageMNV.cs Normal file
View File

@ -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);
}
}
}
}

View File

@ -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")]

View File

@ -100,6 +100,8 @@ Swan Song<br/>
<tr><td>*.dat</td><td>None</td><td>Yes</td><td>Studio e.go!</td><td>Men at Work 2</td></tr>
<tr class="odd"><td>*.mbl</td><td>None</td><td>No</td><td rowspan="2">Marble</td><td rowspan="2">Ikusa Otome Valkyrie</td></tr>
<tr class="odd"><td>*.prs</td><td><tt>YB</tt></td><td>No</td></tr>
<tr><td>*.dat</td><td>None</td><td>No</td><td rowspan="2">M no Violet</td><td rowspan="2">Nanase Ren</td></tr>
<tr><td>*</td><td><tt>gra</tt><br/><tt>mas</tt></td><td>No</td></tr>
</table>
<p><a name="note-1">[1]</a> Non-encrypted only</p>
</body>