From 85962ae01fbf24a0bf67ad25e325450d3f49a4cc Mon Sep 17 00:00:00 2001 From: ManicSteiner Date: Wed, 6 Dec 2023 23:58:24 +0800 Subject: [PATCH] feat: add support of Shin Hayarigami PS3 archive --- ArcFormats/ArcFormats.csproj | 1 + ArcFormats/NipponIchi/ArcCASN.cs | 49 ++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 ArcFormats/NipponIchi/ArcCASN.cs diff --git a/ArcFormats/ArcFormats.csproj b/ArcFormats/ArcFormats.csproj index 77a19a93..512fe8ce 100644 --- a/ArcFormats/ArcFormats.csproj +++ b/ArcFormats/ArcFormats.csproj @@ -172,6 +172,7 @@ + diff --git a/ArcFormats/NipponIchi/ArcCASN.cs b/ArcFormats/NipponIchi/ArcCASN.cs new file mode 100644 index 00000000..fe2eb2c7 --- /dev/null +++ b/ArcFormats/NipponIchi/ArcCASN.cs @@ -0,0 +1,49 @@ +using GameRes.Utility; +using System.Collections.Generic; +using System.ComponentModel.Composition; + +namespace GameRes.Formats.NipponIchi +{ + [Export(typeof(ArchiveFormat))] + public class CASNOpener : ArchiveFormat + { + public override string Tag { get { return "DAT/CASN ShinHayarigami"; } } + public override string Description { get { return "Nippon Ichi Shin Hayarigami PS3 resource archive"; } } + public override uint Signature { get { return 0x4E534143; } } // 'CASN' + public override bool IsHierarchic { get { return false; } } + public override bool CanWrite { get { return false; } } + + public override ArcFile TryOpen(ArcView file) + { + int count = Binary.BigEndian(file.View.ReadUInt16(6)); + long index_offset = count * 10 + 30; //actually count*10 + 28, ignored two bytes of 000C or 000B + var dir = new List(count); + for (int i = 0; i < count; ++i) + { + + uint fstart = Binary.BigEndian(file.View.ReadUInt32(index_offset)); + uint flength = Binary.BigEndian(file.View.ReadUInt32(index_offset + 4)); + index_offset += 8; + byte c; + List namebyte = new List(); + while (true) + { + c = file.View.ReadByte(index_offset); + if (c == 0) break; + namebyte.Add(c); + index_offset++; + } + index_offset += 3; + //var sjis = System.Text.Encoding.GetEncoding("Shift-JIS"); + var name = System.Text.Encoding.ASCII.GetString(namebyte.ToArray()); + var entry = Create(name); + entry.Offset = fstart; + entry.Size = flength; + if (!entry.CheckPlacement(file.MaxOffset)) + return null; + dir.Add(entry); + } + return new ArcFile(file, this, dir); + } + } +}