mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-24 03:44:13 +08:00
fixed GCE1 decompression.
This commit is contained in:
parent
89e594f3bd
commit
dd2c19c8c1
@ -155,10 +155,8 @@ namespace GameRes.Formats.G2
|
|||||||
{
|
{
|
||||||
m_dst = 0;
|
m_dst = 0;
|
||||||
byte[] id = new byte[4];
|
byte[] id = new byte[4];
|
||||||
while (m_input.BaseStream.Position < m_input.BaseStream.Length)
|
while (4 == m_input.Read (id, 0, 4))
|
||||||
{
|
{
|
||||||
if (4 != m_input.Read (id, 0, 4))
|
|
||||||
break;
|
|
||||||
int segment_length = m_input.ReadInt32();
|
int segment_length = m_input.ReadInt32();
|
||||||
if (Binary.AsciiEqual (id, "GCE1"))
|
if (Binary.AsciiEqual (id, "GCE1"))
|
||||||
{
|
{
|
||||||
@ -171,7 +169,7 @@ namespace GameRes.Formats.G2
|
|||||||
ReadControlStream (cmd_pos, cmd_len);
|
ReadControlStream (cmd_pos, cmd_len);
|
||||||
|
|
||||||
int next = m_dst + segment_length;
|
int next = m_dst + segment_length;
|
||||||
UnpackGce1Segment (data_length, segment_length);
|
UnpackGce1Segment (segment_length);
|
||||||
m_dst = next;
|
m_dst = next;
|
||||||
m_input.BaseStream.Position = cmd_pos + cmd_len;
|
m_input.BaseStream.Position = cmd_pos + cmd_len;
|
||||||
}
|
}
|
||||||
@ -190,22 +188,17 @@ namespace GameRes.Formats.G2
|
|||||||
|
|
||||||
int[] m_frame = new int[0x10000];
|
int[] m_frame = new int[0x10000];
|
||||||
|
|
||||||
void UnpackGce1Segment (int data_len, int segment_length)
|
void UnpackGce1Segment (int segment_length)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_frame.Length; ++i)
|
|
||||||
m_frame[i] = 0;
|
|
||||||
int frame_pos = 0;
|
int frame_pos = 0;
|
||||||
|
|
||||||
int data_pos = 0;
|
|
||||||
int dst_end = m_dst + segment_length;
|
int dst_end = m_dst + segment_length;
|
||||||
while (data_pos < data_len && m_dst < dst_end)
|
while (m_dst < dst_end)
|
||||||
{
|
{
|
||||||
int n = GetLength();
|
int n = GetLength();
|
||||||
while (n --> 0)
|
while (n --> 0)
|
||||||
{
|
{
|
||||||
m_frame[frame_pos] = m_dst;
|
m_frame[frame_pos] = m_dst;
|
||||||
byte b = m_input.ReadByte();
|
byte b = m_input.ReadByte();
|
||||||
data_pos++;
|
|
||||||
frame_pos = ((frame_pos << 8) | b) & 0xFFFF;
|
frame_pos = ((frame_pos << 8) | b) & 0xFFFF;
|
||||||
m_output[m_dst++] = b;
|
m_output[m_dst++] = b;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user