mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-27 07:34:00 +08:00
removed redundant ArcView.Reader instances.
This commit is contained in:
parent
375e162959
commit
84985d18f5
@ -82,12 +82,13 @@ namespace GameRes.Formats.Ffa
|
||||
if (!entry.Name.EndsWith (".so4", StringComparison.InvariantCultureIgnoreCase) &&
|
||||
!entry.Name.EndsWith (".so5", StringComparison.InvariantCultureIgnoreCase))
|
||||
return input;
|
||||
using (var header = new ArcView.Reader (input))
|
||||
{
|
||||
int packed = header.ReadInt32();
|
||||
int unpacked = header.ReadInt32();
|
||||
int packed = input.ReadInt32();
|
||||
int unpacked = input.ReadInt32();
|
||||
if (packed+8 != entry.Size || packed <= 0 || unpacked <= 0)
|
||||
{
|
||||
input.Position = 0;
|
||||
return input;
|
||||
}
|
||||
using (input)
|
||||
using (var reader = new LzssReader (input, packed, unpacked))
|
||||
{
|
||||
@ -96,7 +97,6 @@ namespace GameRes.Formats.Ffa
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Export(typeof(ArchiveFormat))]
|
||||
public class JDatOpener : DatOpener
|
||||
|
@ -77,13 +77,13 @@ namespace GameRes.Formats.Glib2
|
||||
stream.Position = 0x20;
|
||||
if (0 != (meta.Flags & 0x1000))
|
||||
{
|
||||
ReadGms (stream.AsStream);
|
||||
ReadGms (stream);
|
||||
}
|
||||
PixelFormat format = 32 == meta.BPP ? PixelFormats.Bgra32 : PixelFormats.Bgr32;
|
||||
int stride = (int)meta.Width * 4;
|
||||
var pixels = new byte[stride * (int)meta.Height];
|
||||
// stream.Seek (-meta.PackedSize, SeekOrigin.End);
|
||||
LzssUnpack (stream.AsStream, pixels);
|
||||
LzssUnpack (stream, pixels);
|
||||
var layer = InfoCache.GetInfo (info.FileName);
|
||||
if (null != layer && null != layer.Rect)
|
||||
{
|
||||
@ -93,7 +93,7 @@ namespace GameRes.Formats.Glib2
|
||||
return ImageData.Create (info, format, null, pixels);
|
||||
}
|
||||
|
||||
void ReadGms (Stream input)
|
||||
void ReadGms (IBinaryStream input)
|
||||
{
|
||||
var header = new byte[0x10];
|
||||
if (0x10 != input.Read (header, 0, 0x10))
|
||||
@ -123,30 +123,28 @@ namespace GameRes.Formats.Glib2
|
||||
throw new System.NotImplementedException ("PgxFormat.Write not implemented");
|
||||
}
|
||||
|
||||
static void LzssUnpack (Stream input, byte[] output)
|
||||
static void LzssUnpack (IBinaryStream input, byte[] output)
|
||||
{
|
||||
var frame = new byte[0x1000];
|
||||
int frame_pos = 0xFEE;
|
||||
using (var lz = new ArcView.Reader (input))
|
||||
{
|
||||
int dst = 0;
|
||||
int bits = 1;
|
||||
while (dst < output.Length)
|
||||
{
|
||||
if (1 == bits)
|
||||
bits = lz.ReadByte() | 0x100;
|
||||
bits = input.ReadUInt8() | 0x100;
|
||||
|
||||
if (0 != (bits & 1))
|
||||
{
|
||||
byte b = lz.ReadByte();
|
||||
byte b = input.ReadUInt8();
|
||||
output[dst++] = b;
|
||||
frame[frame_pos++] = b;
|
||||
frame_pos &= 0xFFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte lo = lz.ReadByte();
|
||||
byte hi = lz.ReadByte();
|
||||
byte lo = input.ReadUInt8();
|
||||
byte hi = input.ReadUInt8();
|
||||
int offset = (hi & 0xF0) << 4 | lo;
|
||||
int count = Math.Min ((~hi & 0xF) + 3, output.Length-dst);
|
||||
for (int i = 0; i < count; ++i)
|
||||
@ -161,7 +159,6 @@ namespace GameRes.Formats.Glib2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class InfoReader
|
||||
{
|
||||
|
@ -97,18 +97,15 @@ namespace GameRes.Formats.Kaguya
|
||||
|
||||
public byte[] Data { get { return m_output; } }
|
||||
|
||||
public BmrDecoder (Stream input)
|
||||
public BmrDecoder (IBinaryStream input)
|
||||
{
|
||||
input.Position = 3;
|
||||
using (var header = new ArcView.Reader (input))
|
||||
{
|
||||
m_step = header.ReadByte();
|
||||
m_final_size = header.ReadInt32();
|
||||
m_key = header.ReadInt32();
|
||||
int unpacked_size = header.ReadInt32();
|
||||
m_step = input.ReadUInt8();
|
||||
m_final_size = input.ReadInt32();
|
||||
m_key = input.ReadInt32();
|
||||
int unpacked_size = input.ReadInt32();
|
||||
m_output = new byte[unpacked_size];
|
||||
m_input = new MsbBitStream (input, true);
|
||||
}
|
||||
m_input = new MsbBitStream (input.AsStream, true);
|
||||
}
|
||||
|
||||
public void Unpack ()
|
||||
|
@ -54,7 +54,6 @@ namespace GameRes.Formats.Kiss
|
||||
|
||||
var dir = new List<Entry> (count);
|
||||
using (var input = file.CreateStream())
|
||||
using (var reader = new ArcView.Reader (input))
|
||||
{
|
||||
long prev_offset = 4;
|
||||
input.Position = 4;
|
||||
@ -64,7 +63,7 @@ namespace GameRes.Formats.Kiss
|
||||
if (string.IsNullOrWhiteSpace (name))
|
||||
return null;
|
||||
var entry = FormatCatalog.Instance.Create<Entry> (name);
|
||||
entry.Offset = reader.ReadInt64();
|
||||
entry.Offset = input.ReadInt64();
|
||||
if (entry.Offset < prev_offset || entry.Offset > file.MaxOffset)
|
||||
return null;
|
||||
dir.Add (entry);
|
||||
|
@ -108,14 +108,13 @@ namespace GameRes.Formats.SuperNekoX
|
||||
void DetectFileTypes (ArcView file, List<Entry> dir)
|
||||
{
|
||||
using (var input = file.CreateStream())
|
||||
using (var reader = new ArcView.Reader (input))
|
||||
{
|
||||
var buffer = new byte[0x10];
|
||||
foreach (PackedEntry entry in dir)
|
||||
{
|
||||
input.Position = entry.Offset;
|
||||
uint packed_size = reader.ReadUInt32();
|
||||
entry.UnpackedSize = reader.ReadUInt32();
|
||||
uint packed_size = input.ReadUInt32();
|
||||
entry.UnpackedSize = input.ReadUInt32();
|
||||
entry.Offset += 8;
|
||||
if (0 == packed_size)
|
||||
{
|
||||
@ -135,7 +134,7 @@ namespace GameRes.Formats.SuperNekoX
|
||||
signature = LittleEndian.ToUInt32 (buffer, 0);
|
||||
}
|
||||
else
|
||||
signature = reader.ReadUInt32();
|
||||
signature = input.ReadUInt32();
|
||||
IResource res;
|
||||
if (0x020000 == signature || 0x0A0000 == signature)
|
||||
res = ImageFormat.Tga;
|
||||
|
Loading…
Reference in New Issue
Block a user