Stream OpenAudio(ArcFile arc, Entry entry) { int unpacked_size = arc.File.View.ReadInt32(entry.Offset); byte pack_type = arc.File.View.ReadByte(entry.Offset + 5); byte channels = arc.File.View.ReadByte(entry.Offset + 6); byte header_size = arc.File.View.ReadByte(entry.Offset + 7); if (unpacked_size <= 0 || header_size > unpacked_size || !('A' == pack_type || 'S' == pack_type)) { return(base.OpenEntry(arc, entry)); } var unpacked = new byte[unpacked_size]; arc.File.View.Read(entry.Offset + 8, unpacked, 0, header_size); uint packed_size = entry.Size - 8 - header_size; using (var packed = arc.File.CreateStream(entry.Offset + 8 + header_size, packed_size)) using (var reader = new GrpUnpacker(packed)) { if ('A' == pack_type) { reader.UnpackA(unpacked, header_size, channels); } else { reader.UnpackS(unpacked, header_size, channels); } return(new BinMemoryStream(unpacked, entry.Name)); } }
Stream OpenImage(ArcFile arc, PackedEntry entry) { using (var packed = arc.File.CreateStream(entry.Offset + 8, entry.Size - 8)) using (var reader = new GrpUnpacker(packed)) { var unpacked = new byte[entry.UnpackedSize]; reader.UnpackHDJ(unpacked, 0); return(new BinMemoryStream(unpacked, entry.Name)); } }
Stream OpenImage(ArcFile arc, Entry entry) { int unpacked_size = arc.File.View.ReadInt32(entry.Offset); if (unpacked_size <= 0) { return(base.OpenEntry(arc, entry)); } using (var packed = arc.File.CreateStream(entry.Offset + 8, entry.Size - 8)) using (var reader = new GrpUnpacker(packed)) { var unpacked = new byte[unpacked_size]; reader.UnpackHDJ(unpacked, 0); return(new MemoryStream(unpacked)); } }
Stream OpenImage(ArcFile arc, Entry entry) { int unpacked_size = arc.File.View.ReadInt32 (entry.Offset); if (unpacked_size <= 0) return base.OpenEntry (arc, entry); using (var packed = arc.File.CreateStream (entry.Offset+8, entry.Size-8)) using (var reader = new GrpUnpacker (packed)) { var unpacked = new byte[unpacked_size]; reader.UnpackHDJ (unpacked, 0); return new MemoryStream (unpacked); } }
Stream OpenAudio(ArcFile arc, Entry entry) { int unpacked_size = arc.File.View.ReadInt32 (entry.Offset); byte pack_type = arc.File.View.ReadByte (entry.Offset+5); byte channels = arc.File.View.ReadByte (entry.Offset+6); byte header_size = arc.File.View.ReadByte (entry.Offset+7); if (unpacked_size <= 0 || header_size > unpacked_size || !('A' == pack_type || 'S' == pack_type)) return base.OpenEntry (arc, entry); var unpacked = new byte[unpacked_size]; arc.File.View.Read (entry.Offset+8, unpacked, 0, header_size); uint packed_size = entry.Size - 8 - header_size; using (var packed = arc.File.CreateStream (entry.Offset+8+header_size, packed_size)) using (var reader = new GrpUnpacker (packed)) { if ('A' == pack_type) reader.UnpackA (unpacked, header_size, channels); else reader.UnpackS (unpacked, header_size, channels); return new MemoryStream (unpacked); } }