mirror of
https://github.com/crskycode/GARbro.git
synced 2025-01-11 20:39:29 +08:00
(AgfFormat): correctly read [non]compressed file sections.
This commit is contained in:
parent
46c4d4c2f0
commit
df4b5960f7
@ -62,14 +62,9 @@ namespace GameRes.Formats.Eushully
|
|||||||
int type = LittleEndian.ToInt32 (header, 4);
|
int type = LittleEndian.ToInt32 (header, 4);
|
||||||
if (type != 1 && type != 2)
|
if (type != 1 && type != 2)
|
||||||
return null;
|
return null;
|
||||||
uint unpacked_size = LittleEndian.ToUInt32 (header, 0x10);
|
int unpacked_size = LittleEndian.ToInt32 (header, 0x10);
|
||||||
uint packed_size = LittleEndian.ToUInt32 (header, 0x14);
|
int packed_size = LittleEndian.ToInt32 (header, 0x14);
|
||||||
Stream unpacked;
|
using (var unpacked = AgfReader.OpenSection (stream, unpacked_size, packed_size))
|
||||||
if (unpacked_size != packed_size)
|
|
||||||
unpacked = new LzssStream (stream, LzssMode.Decompress, true);
|
|
||||||
else
|
|
||||||
unpacked = new StreamRegion (stream, stream.Position, packed_size, true);
|
|
||||||
using (unpacked)
|
|
||||||
using (var reader = new BinaryReader (unpacked))
|
using (var reader = new BinaryReader (unpacked))
|
||||||
{
|
{
|
||||||
if (0x20 != reader.Read (header, 0, 0x20))
|
if (0x20 != reader.Read (header, 0, 0x20))
|
||||||
@ -80,7 +75,7 @@ namespace GameRes.Formats.Eushully
|
|||||||
Height = LittleEndian.ToUInt32 (header, 0x18),
|
Height = LittleEndian.ToUInt32 (header, 0x18),
|
||||||
BPP = 1 == type ? 24 : 32,
|
BPP = 1 == type ? 24 : 32,
|
||||||
SourceBPP = LittleEndian.ToInt16 (header, 0x1E),
|
SourceBPP = LittleEndian.ToInt16 (header, 0x1E),
|
||||||
DataOffset = 0x18 + packed_size,
|
DataOffset = 0x18 + (uint)packed_size,
|
||||||
};
|
};
|
||||||
if (0 == info.SourceBPP)
|
if (0 == info.SourceBPP)
|
||||||
return null;
|
return null;
|
||||||
@ -108,11 +103,7 @@ namespace GameRes.Formats.Eushully
|
|||||||
|
|
||||||
public override ImageData Read (Stream stream, ImageMetaData info)
|
public override ImageData Read (Stream stream, ImageMetaData info)
|
||||||
{
|
{
|
||||||
var meta = info as AgfMetaData;
|
using (var reader = new AgfReader (stream, (AgfMetaData)info))
|
||||||
if (null == meta)
|
|
||||||
throw new ArgumentException ("AgfFormat.Read should be supplied with AgfMetaData", "info");
|
|
||||||
|
|
||||||
using (var reader = new AgfReader (stream, meta))
|
|
||||||
{
|
{
|
||||||
reader.Unpack();
|
reader.Unpack();
|
||||||
return ImageData.Create (info, reader.Format, null, reader.Data);
|
return ImageData.Create (info, reader.Format, null, reader.Data);
|
||||||
@ -151,6 +142,14 @@ namespace GameRes.Formats.Eushully
|
|||||||
m_palette = info.Palette;
|
m_palette = info.Palette;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Stream OpenSection (Stream stream, int unpacked_size, int packed_size)
|
||||||
|
{
|
||||||
|
if (unpacked_size != packed_size)
|
||||||
|
return new LzssStream (stream, LzssMode.Decompress, true);
|
||||||
|
else
|
||||||
|
return new StreamRegion (stream, stream.Position, packed_size, true);
|
||||||
|
}
|
||||||
|
|
||||||
public void Unpack ()
|
public void Unpack ()
|
||||||
{
|
{
|
||||||
m_input.ReadInt32();
|
m_input.ReadInt32();
|
||||||
@ -158,11 +157,9 @@ namespace GameRes.Formats.Eushully
|
|||||||
int packed_size = m_input.ReadInt32();
|
int packed_size = m_input.ReadInt32();
|
||||||
var data_pos = m_input.BaseStream.Position;
|
var data_pos = m_input.BaseStream.Position;
|
||||||
var bmp_data = new byte[data_size];
|
var bmp_data = new byte[data_size];
|
||||||
using (var unpacked = new LzssStream (m_input.BaseStream, LzssMode.Decompress, true))
|
using (var unpacked = OpenSection (m_input.BaseStream, data_size, packed_size))
|
||||||
{
|
|
||||||
if (data_size != unpacked.Read (bmp_data, 0, data_size))
|
if (data_size != unpacked.Read (bmp_data, 0, data_size))
|
||||||
throw new EndOfStreamException();
|
throw new EndOfStreamException();
|
||||||
}
|
|
||||||
byte[] alpha = null;
|
byte[] alpha = null;
|
||||||
if (32 == m_bpp)
|
if (32 == m_bpp)
|
||||||
{
|
{
|
||||||
@ -230,10 +227,11 @@ namespace GameRes.Formats.Eushully
|
|||||||
if (!Binary.AsciiEqual (header, 0, "ACIF"))
|
if (!Binary.AsciiEqual (header, 0, "ACIF"))
|
||||||
return null;
|
return null;
|
||||||
int unpacked_size = LittleEndian.ToInt32 (header, 0x1C);
|
int unpacked_size = LittleEndian.ToInt32 (header, 0x1C);
|
||||||
|
int packed_size = LittleEndian.ToInt32 (header, 0x20);
|
||||||
if (m_width*m_height != unpacked_size)
|
if (m_width*m_height != unpacked_size)
|
||||||
return null;
|
return null;
|
||||||
var alpha = new byte[unpacked_size];
|
var alpha = new byte[unpacked_size];
|
||||||
using (var unpacked = new LzssStream (m_input.BaseStream, LzssMode.Decompress, true))
|
using (var unpacked = OpenSection (m_input.BaseStream, unpacked_size, packed_size))
|
||||||
if (unpacked_size != unpacked.Read (alpha, 0, unpacked_size))
|
if (unpacked_size != unpacked.Read (alpha, 0, unpacked_size))
|
||||||
return null;
|
return null;
|
||||||
return alpha;
|
return alpha;
|
||||||
|
@ -324,6 +324,7 @@ Ore-tachi ni Tsubasa wa Nai<br/>
|
|||||||
Rikorisu ~Lycoris Radiata~<br/>
|
Rikorisu ~Lycoris Radiata~<br/>
|
||||||
Sakura Synchronicity<br/>
|
Sakura Synchronicity<br/>
|
||||||
Shinsetsu Ryouki no Ori Dai 2 Shou<br/>
|
Shinsetsu Ryouki no Ori Dai 2 Shou<br/>
|
||||||
|
Shuffle! Essence+<br/>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr class="odd"><td>*.elg</td><td><tt>ELG</tt></td><td>No</td></tr>
|
<tr class="odd"><td>*.elg</td><td><tt>ELG</tt></td><td>No</td></tr>
|
||||||
<tr><td>*.arc</td><td><tt>ARC\x1a</tt><br><tt>ARC</tt></td><td>No</td><td rowspan="2">AZ System</td><td rowspan="2">
|
<tr><td>*.arc</td><td><tt>ARC\x1a</tt><br><tt>ARC</tt></td><td>No</td><td rowspan="2">AZ System</td><td rowspan="2">
|
||||||
@ -536,6 +537,7 @@ Tetsuwan Gacchu!<br/>
|
|||||||
Gigai no Alruna<br/>
|
Gigai no Alruna<br/>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr class="odd"><td>sys4ini.bin<br/>sys3ini.bin<br/>*.alf</td><td><tt>S4IC</tt><br/><tt>S3IC</tt></td><td>No</td><td rowspan="2">Eushully</td><td rowspan="2">
|
<tr class="odd"><td>sys4ini.bin<br/>sys3ini.bin<br/>*.alf</td><td><tt>S4IC</tt><br/><tt>S3IC</tt></td><td>No</td><td rowspan="2">Eushully</td><td rowspan="2">
|
||||||
|
Kuutei Senki ~Tasogare ni Shizumu Kusabi~<br/>
|
||||||
Soukai no Oujo-tachi<br/>
|
Soukai no Oujo-tachi<br/>
|
||||||
Soukai no Valkyria <br/>
|
Soukai no Valkyria <br/>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user