From 200a05db81833f6969db421674a7817f027f66fd Mon Sep 17 00:00:00 2001 From: ManicSteiner Date: Sun, 24 Dec 2023 00:50:16 +0800 Subject: [PATCH] fix: PS2 BIP Compress --- ArcFormats/Cri/ArcSPC.cs | 4 ++-- ArcFormats/Kid/ImageBIP.cs | 20 +++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ArcFormats/Cri/ArcSPC.cs b/ArcFormats/Cri/ArcSPC.cs index 91272a99..1185d556 100644 --- a/ArcFormats/Cri/ArcSPC.cs +++ b/ArcFormats/Cri/ArcSPC.cs @@ -42,12 +42,12 @@ namespace GameRes.Formats.Cri public SpcOpener () { - Extensions = new string[] { "spc" }; + Extensions = new string[] { "spc", "bip" }; } public override ArcFile TryOpen (ArcView file) { - if (!file.Name.HasExtension (".spc")) + if (!file.Name.HasExtension (".spc") && !file.Name.HasExtension(".bip")) return null; uint unpacked_size = file.View.ReadUInt32 (0); if (unpacked_size <= 0x20 || unpacked_size > 0x5000000) diff --git a/ArcFormats/Kid/ImageBIP.cs b/ArcFormats/Kid/ImageBIP.cs index 7e8eb9b3..d3883512 100644 --- a/ArcFormats/Kid/ImageBIP.cs +++ b/ArcFormats/Kid/ImageBIP.cs @@ -28,24 +28,27 @@ namespace GameRes.Formats.Kid } file.Seek(0x14, SeekOrigin.Begin); - if (file.ReadUInt16() != 256) + if ((file.ReadUInt16() & 0x7FFF) != 256) { return null; } uint sign = file.ReadUInt16(); uint dy; bool sliced = true; - if (sign == 0x17) + if (sign == 0x17 || sign == 0x19 || sign == 0x1F || sign == 0x25 || sign == 0x2E || sign == 0x34) { + //sign = focusT / 2 dy = 16; } else if (sign == 0x13) { + //sign = focusT / 2 dy = 16; sliced = false; } - else if (sign == 0x16) + else if (sign == 0x16 || sign == 0x20 || sign == 0x2A) { + //sign = focusT * 2 dy = 32; } else @@ -57,13 +60,16 @@ namespace GameRes.Formats.Kid file.Seek(0x88, SeekOrigin.Begin); uint width = file.ReadUInt16(); uint height = file.ReadUInt16(); - if (width >= 1280 || height >= 1280 || width == 0 || height == 0) // suppose not so large + if (width > 2560 || height > 1440 || width < 16 || height < 16) // suppose not so large return null; file.Seek(0x90, SeekOrigin.Begin); - uint size = file.ReadUInt32(); - size &= 0x00FFFFFF; - if (sign == 0x13 && size != (file.Length - 0x100) || sign == 0x17 && size != (file.Length - 0x100)* 2) + //uint size = file.ReadUInt32(); // not size + uint sizesign = file.ReadUInt16(); + uint sizesign_high = file.ReadUInt16(); + //size &= 0x00FFFFFF; + //if (sign == 0x13 && size != (file.Length - 0x100) || sign == 0x17 && size != (file.Length - 0x100)* 2) + if (sizesign != 0 || sizesign_high == 0) { return null; }