From 3650164c2d32769e54efc448b3238325a13ad126 Mon Sep 17 00:00:00 2001 From: morkt Date: Mon, 6 Apr 2015 17:05:41 +0400 Subject: [PATCH] added another A98SYS engine archive version. --- ArcFormats/ArcADPACK.cs | 53 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/ArcFormats/ArcADPACK.cs b/ArcFormats/ArcADPACK.cs index f7f06379..6ecb99ee 100644 --- a/ArcFormats/ArcADPACK.cs +++ b/ArcFormats/ArcADPACK.cs @@ -1,6 +1,6 @@ //! \file ArcADPACK.cs //! \date Sun Feb 15 09:25:28 2015 -//! \brief ADPACK32 archive format implementation. +//! \brief A98SYS engine archive formats implementation. // // Copyright (C) 2015 by morkt // @@ -33,6 +33,53 @@ namespace GameRes.Formats.AdPack { [Export(typeof(ArchiveFormat))] public class PakOpener : ArchiveFormat + { + public override string Tag { get { return "A98"; } } + public override string Description { get { return "A98SYS Engine resource archive"; } } + public override uint Signature { get { return 0; } } + public override bool IsHierarchic { get { return false; } } + public override bool CanCreate { get { return false; } } + + public PakOpener () + { + Extensions = new string[] { "pak" }; + } + + public override ArcFile TryOpen (ArcView file) + { + int count = file.View.ReadInt16 (0); + if (count <= 1) + return null; + long index_offset = 2; + uint index_size = (uint)(0x10 * count); + if (index_size > file.View.Reserve (index_offset, index_size)) + return null; + --count; + var dir = new List (count); + for (uint i = 0; i < count; ++i) + { + string name = file.View.ReadString (index_offset, 8).TrimEnd (null); + if (0 == name.Length) + return null; + string ext = file.View.ReadString (index_offset+8, 4).TrimEnd (null); + if (0 != ext.Length) + name += '.'+ext; + var entry = FormatCatalog.Instance.CreateEntry (name); + uint offset = file.View.ReadUInt32 (index_offset+12); + uint next_offset = file.View.ReadUInt32 (index_offset+0x10+12); + entry.Size = next_offset - offset; + entry.Offset = offset; + if (offset < index_size || !entry.CheckPlacement (file.MaxOffset)) + return null; + dir.Add (entry); + index_offset += 0x10; + } + return new ArcFile (file, this, dir); + } + } + + [Export(typeof(ArchiveFormat))] + public class Pak32Opener : ArchiveFormat { public override string Tag { get { return "ADPACK32"; } } public override string Description { get { return "Active Soft resource archive"; } } @@ -40,7 +87,7 @@ namespace GameRes.Formats.AdPack public override bool IsHierarchic { get { return false; } } public override bool CanCreate { get { return false; } } - public PakOpener () + public Pak32Opener () { Extensions = new string[] { "pak" }; } @@ -55,7 +102,7 @@ namespace GameRes.Formats.AdPack uint index_size = (uint)(0x20 * count); if (index_size > file.View.Reserve (0x10, index_size)) return null; - var dir = new List ((int)count); + var dir = new List (count); long index_offset = 0x10; for (uint i = 0; i < count; ++i) {