added BURIKO ARC20 archives reader.

This commit is contained in:
morkt 2015-08-29 22:10:59 +04:00
parent fdd5a2aba6
commit a0ae95d1ef
2 changed files with 40 additions and 26 deletions

View File

@ -83,30 +83,7 @@ namespace GameRes.Formats.BGI
using (var decoder = new DscDecoder (input)) using (var decoder = new DscDecoder (input))
{ {
decoder.Unpack(); decoder.Unpack();
byte[] data = decoder.Output; return new MemoryStream (decoder.Output);
if (data.Length > 0x40)
{
uint data_offset = LittleEndian.ToUInt32 (data, 0);
if (data_offset < data.Length-4 && 0x20207762 == LittleEndian.ToUInt32 (data, 4))
{
if (0x5367674f == LittleEndian.ToUInt32 (data, (int)data_offset)) // 'OggS'
{
return new MemoryStream (data, (int)data_offset, data.Length-(int)data_offset, false);
}
}
}
return new MemoryStream (data, false);
}
}
if (entry.Size > 0x40)
{
uint data_offset = input.ReadUInt32 (entry_offset);
if (data_offset < entry.Size-4 && 0x20207762 == input.ReadUInt32 (entry_offset+4))
{
if (0x5367674f == input.ReadUInt32 (entry_offset+data_offset)) // 'OggS'
{
return new ArcView.ArcStream (input, entry_offset+data_offset, entry.Size-data_offset);
}
} }
} }
return new ArcView.ArcStream (input); return new ArcView.ArcStream (input);
@ -119,6 +96,43 @@ namespace GameRes.Formats.BGI
} }
} }
[Export(typeof(ArchiveFormat))]
public class Arc2Opener : ArcOpener
{
public override string Tag { get { return "BURIKO ARC"; } }
public override string Description { get { return "BGI/Ethornell engine resource archive v2"; } }
public override uint Signature { get { return 0x49525542; } } // "BURI"
public override bool IsHierarchic { get { return false; } }
public override bool CanCreate { get { return false; } }
public override ArcFile TryOpen (ArcView file)
{
if (!file.View.AsciiEqual (4, "KO ARC20"))
return null;
int count = file.View.ReadInt32 (12);
if (!IsSaneCount (count))
return null;
uint index_size = 0x80 * (uint)count;
if (index_size > file.View.Reserve (0x10, index_size))
return null;
var dir = new List<Entry> (count);
long index_offset = 0x10;
long base_offset = index_offset + index_size;
for (uint i = 0; i < count; ++i)
{
string name = file.View.ReadString (index_offset, 0x60);
var entry = FormatCatalog.Instance.CreateEntry (name);
entry.Offset = base_offset + file.View.ReadUInt32 (index_offset+0x60);
entry.Size = file.View.ReadUInt32 (index_offset+0x64);
if (!entry.CheckPlacement (file.MaxOffset))
return null;
dir.Add (entry);
index_offset += 0x80;
}
return new ArcFile (file, this, dir);
}
}
internal class BgiDecoderBase : MsbBitStream internal class BgiDecoderBase : MsbBitStream
{ {
protected uint m_key; protected uint m_key;

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 // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion ("1.1.9.406")] [assembly: AssemblyVersion ("1.1.9.414")]
[assembly: AssemblyFileVersion ("1.1.9.406")] [assembly: AssemblyFileVersion ("1.1.9.414")]