From 5292d3c9c8897633ce4ad7e98e6aa99233f5d9e1 Mon Sep 17 00:00:00 2001 From: ManicSteiner Date: Thu, 14 Dec 2023 22:58:43 +0800 Subject: [PATCH] feat: DAT/FARC MAGES Rozen Maiden PS3 archive --- ArcFormats/ArcFormats.csproj | 1 + ArcFormats/MAGES/ArcFARC.cs | 48 ++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 ArcFormats/MAGES/ArcFARC.cs diff --git a/ArcFormats/ArcFormats.csproj b/ArcFormats/ArcFormats.csproj index 211acb36..6cc91afa 100644 --- a/ArcFormats/ArcFormats.csproj +++ b/ArcFormats/ArcFormats.csproj @@ -172,6 +172,7 @@ + diff --git a/ArcFormats/MAGES/ArcFARC.cs b/ArcFormats/MAGES/ArcFARC.cs new file mode 100644 index 00000000..5e79ce51 --- /dev/null +++ b/ArcFormats/MAGES/ArcFARC.cs @@ -0,0 +1,48 @@ +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.Text; + +namespace GameRes.Formats.MAGES +{ + [Export(typeof(ArchiveFormat))] + public class FARCOpener : ArchiveFormat + { + public override string Tag { get { return "DAT/FARC Rozen Maiden PS3 archive"; } } + public override string Description { get { return "MAGES Rozen Maiden Wechseln Sie Welt ab PS3 BLJM61120 archive"; } } + public override uint Signature { get { return 0x43524146; } } // 'FARC' + public override bool IsHierarchic { get { return false; } } + public override bool CanWrite { get { return false; } } + + public override ArcFile TryOpen(ArcView file) + { + int count = file.View.ReadInt32(20); + if (!IsSaneCount(count)) + return null; + uint datanamestart = (uint)count * 20 + 36; + var dir = new List(count); + for (int i = 0; i < count; ++i) + { + long namepl = file.View.ReadUInt32(20 * i + 36 + 16); + long index_offset = datanamestart + namepl; + byte c; + List namebyte = new List(); + while (true) + { + c = file.View.ReadByte(index_offset); + if (c == 0) break; + namebyte.Add(c); + index_offset++; + } + var sjis = Encoding.GetEncoding("Shift-JIS"); + var name = sjis.GetString(namebyte.ToArray()); + var entry = Create(name); + entry.Offset = file.View.ReadUInt32(20 * i + 36); + entry.Size = file.View.ReadUInt32(20 * i + 36 + 4); + if (entry.Size == 0) + continue; + dir.Add(entry); + } + return new ArcFile(file, this, dir); + } + } +}