mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-27 07:34:00 +08:00
implemented Malie script engine resources.
- *.lib archives - *.mgf images
This commit is contained in:
parent
efe0c82de0
commit
781ad04b95
@ -94,6 +94,7 @@
|
||||
<Compile Include="ArcKaguya.cs" />
|
||||
<Compile Include="ArcKCAP.cs" />
|
||||
<Compile Include="ArcKogado.cs" />
|
||||
<Compile Include="ArcLIB.cs" />
|
||||
<Compile Include="ArcLPK.cs" />
|
||||
<Compile Include="ArcLST.cs" />
|
||||
<Compile Include="ArcMAI.cs" />
|
||||
@ -191,6 +192,7 @@
|
||||
<Compile Include="ImageKAAS.cs" />
|
||||
<Compile Include="ImageMAI.cs" />
|
||||
<Compile Include="ImageMFG.cs" />
|
||||
<Compile Include="ImageMGF.cs" />
|
||||
<Compile Include="ImageMNV.cs" />
|
||||
<Compile Include="ImagePMP.cs" />
|
||||
<Compile Include="ImagePRS.cs" />
|
||||
|
106
ArcFormats/ArcLIB.cs
Normal file
106
ArcFormats/ArcLIB.cs
Normal file
@ -0,0 +1,106 @@
|
||||
//! \file ArcLIB.cs
|
||||
//! \date Thu Jun 25 06:46:51 2015
|
||||
//! \brief Malie System archive 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.Malie
|
||||
{
|
||||
[Export(typeof(ArchiveFormat))]
|
||||
public class LibOpener : ArchiveFormat
|
||||
{
|
||||
public override string Tag { get { return "LIB"; } }
|
||||
public override string Description { get { return "Malie engine resource archive"; } }
|
||||
public override uint Signature { get { return 0x0042494C; } } // 'LIB'
|
||||
public override bool IsHierarchic { get { return true; } }
|
||||
public override bool CanCreate { get { return false; } }
|
||||
|
||||
public override ArcFile TryOpen (ArcView file)
|
||||
{
|
||||
var reader = new Reader (file);
|
||||
if (reader.ReadIndex ("", 0, (uint)file.MaxOffset))
|
||||
return new ArcFile (file, this, reader.Dir);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
internal class Reader
|
||||
{
|
||||
ArcView.Frame m_view;
|
||||
List<Entry> m_dir = new List<Entry>();
|
||||
|
||||
public List<Entry> Dir { get { return m_dir; } }
|
||||
|
||||
public Reader (ArcView file)
|
||||
{
|
||||
m_view = file.View;
|
||||
}
|
||||
|
||||
public bool ReadIndex (string root, long base_offset, uint size)
|
||||
{
|
||||
uint signature = m_view.ReadUInt32 (base_offset);
|
||||
if (0x0042494C != signature)
|
||||
return false;
|
||||
|
||||
int count = m_view.ReadInt16 (base_offset + 8);
|
||||
if (count <= 0)
|
||||
return false;
|
||||
long index_offset = base_offset + 0x10;
|
||||
uint index_size = (uint)(0x30 * count);
|
||||
if (index_size > size)
|
||||
return false;
|
||||
if (index_size > m_view.Reserve (index_offset, index_size))
|
||||
return false;
|
||||
long data_offset = index_offset + index_size;
|
||||
if (m_dir.Capacity < m_dir.Count + count)
|
||||
m_dir.Capacity = m_dir.Count + count;
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
string name = m_view.ReadString (index_offset, 0x24);
|
||||
uint entry_size = m_view.ReadUInt32 (index_offset+0x24);
|
||||
long offset = base_offset + m_view.ReadUInt32 (index_offset+0x28);
|
||||
index_offset += 0x30;
|
||||
string ext = Path.GetExtension (name);
|
||||
name = Path.Combine (root, name);
|
||||
if (string.IsNullOrEmpty (ext) && ReadIndex (name, offset, entry_size))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (offset < data_offset || offset + entry_size > base_offset + size)
|
||||
return false;
|
||||
|
||||
var entry = FormatCatalog.Instance.CreateEntry (name);
|
||||
entry.Offset = offset;
|
||||
entry.Size = entry_size;
|
||||
m_dir.Add (entry);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
76
ArcFormats/ImageMGF.cs
Normal file
76
ArcFormats/ImageMGF.cs
Normal file
@ -0,0 +1,76 @@
|
||||
//! \file ImageMGF.cs
|
||||
//! \date Thu Jun 25 06:08:32 2015
|
||||
//! \brief Malie System image format.
|
||||
//
|
||||
// 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.Text;
|
||||
using GameRes.Utility;
|
||||
|
||||
namespace GameRes.Formats.Malie
|
||||
{
|
||||
[Export(typeof(ImageFormat))]
|
||||
public class MgfFormat : PngFormat
|
||||
{
|
||||
public override string Tag { get { return "MGF"; } }
|
||||
public override string Description { get { return "Malie engine image format"; } }
|
||||
public override uint Signature { get { return 0x696C614D; } } // 'Mali'
|
||||
|
||||
static readonly byte[] PngHeader = { 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A };
|
||||
|
||||
public override ImageMetaData ReadMetaData (Stream stream)
|
||||
{
|
||||
var header = new byte[8];
|
||||
if (8 != stream.Read (header, 0, 8))
|
||||
return null;
|
||||
if (!Binary.AsciiEqual (header, "MalieGF"))
|
||||
return null;
|
||||
Buffer.BlockCopy (PngHeader, 0, header, 0, 8);
|
||||
|
||||
using (var data = new StreamRegion (stream, 8, stream.Length - 8, true))
|
||||
using (var png = new PrefixStream (header, data))
|
||||
return base.ReadMetaData (png);
|
||||
}
|
||||
|
||||
public override ImageData Read (Stream stream, ImageMetaData info)
|
||||
{
|
||||
var header = PngHeader.Clone() as byte[];
|
||||
using (var data = new StreamRegion (stream, 8, stream.Length - 8, true))
|
||||
using (var png = new PrefixStream (header, data))
|
||||
return base.Read (png, info);
|
||||
}
|
||||
|
||||
public override void Write (Stream file, ImageData image)
|
||||
{
|
||||
using (var png = new MemoryStream())
|
||||
{
|
||||
base.Write (png, image);
|
||||
var buffer = png.GetBuffer();
|
||||
Encoding.ASCII.GetBytes ("MalieGF\0", 0, 8, buffer, 0);
|
||||
file.Write (buffer, 0, (int)png.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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.7.68")]
|
||||
[assembly: AssemblyFileVersion ("1.0.7.68")]
|
||||
[assembly: AssemblyVersion ("1.0.7.69")]
|
||||
[assembly: AssemblyFileVersion ("1.0.7.69")]
|
||||
|
@ -220,6 +220,10 @@ Maid no Yakata ~Zetsubou Hen~<br/>
|
||||
Double<br/>
|
||||
Kimon Youitan<br/>
|
||||
</td></tr>
|
||||
<tr class="odd"><td>*.lib</td><td><tt>LIB</tt></td><td>No</td><td rowspan="2">Malie</td><td rowspan="2">
|
||||
Angel Crown<br/>
|
||||
</td></tr>
|
||||
<tr class="odd"><td>*.mgf</td><td><tt>MalieGF</tt></td><td>Yes</td></tr>
|
||||
</table>
|
||||
<p><a name="note-1">[1]</a> Non-encrypted only</p>
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user