From 8188874e81dc5e5fc7b71c68e34c0142feafbbf4 Mon Sep 17 00:00:00 2001 From: ManicSteiner Date: Thu, 7 Dec 2023 22:52:36 +0800 Subject: [PATCH] feat: add support of Pia Carrot e Youkoso 4 Xbox360 archive --- ArcFormats/ArcFormats.csproj | 1 + ArcFormats/FC01/ArcSCXA.cs | 50 ++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 ArcFormats/FC01/ArcSCXA.cs diff --git a/ArcFormats/ArcFormats.csproj b/ArcFormats/ArcFormats.csproj index f8f12629..4aac478c 100644 --- a/ArcFormats/ArcFormats.csproj +++ b/ArcFormats/ArcFormats.csproj @@ -127,6 +127,7 @@ + diff --git a/ArcFormats/FC01/ArcSCXA.cs b/ArcFormats/FC01/ArcSCXA.cs new file mode 100644 index 00000000..23f52246 --- /dev/null +++ b/ArcFormats/FC01/ArcSCXA.cs @@ -0,0 +1,50 @@ +using System.Collections.Generic; +using System.ComponentModel.Composition; + +namespace GameRes.Formats.FC01 +{ + [Export(typeof(ArchiveFormat))] + public class SCXAOpener : ArchiveFormat + { + public override string Tag { get { return "ARC/SCXA Pia Carrot e Youkoso 4 Xbox360"; } } + public override string Description { get { return "Pia Carrot e Youkoso 4 Xbox360 resource archive"; } } + public override uint Signature { get { return 0x41584353; } } // 'SCXA' + public override bool IsHierarchic { get { return false; } } + public override bool CanWrite { get { return false; } } + + public override ArcFile TryOpen(ArcView file) + { + uint datastart = file.View.ReadUInt32(4); + int count = file.View.ReadInt32(8); + if (!IsSaneCount(count)) + return null; + uint tnstart = (uint)count * 4 + 12; + var dir = new List(count); + uint index_offset; + for (int i = 0; i < count; ++i) + { + uint namestart = file.View.ReadUInt32(i * 4 + 12); + uint fstart = file.View.ReadUInt32(tnstart + namestart); + uint flength = file.View.ReadUInt32(tnstart + namestart + 4); + index_offset = tnstart + namestart + 8; + byte c; + List namebyte = new List(); + while (true) + { + c = file.View.ReadByte((long)index_offset); + if (c == 0 | index_offset > datastart) break; + namebyte.Add(c); + index_offset++; + } + var name = System.Text.Encoding.ASCII.GetString(namebyte.ToArray()); + var entry = Create(name); + entry.Offset = datastart + fstart; + entry.Size = flength; + if (!entry.CheckPlacement(file.MaxOffset)) + return null; + dir.Add(entry); + } + return new ArcFile(file, this, dir); + } + } +}