mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Port GARC decoder to Construct 2.8
This commit is contained in:
parent
a38cb37e90
commit
d7c20809e5
1 changed files with 17 additions and 23 deletions
|
@ -26,34 +26,28 @@ def count_bits(n):
|
||||||
|
|
||||||
|
|
||||||
garc_header_struct = c.Struct(
|
garc_header_struct = c.Struct(
|
||||||
'garc_header',
|
c.Const(b'CRAG'),
|
||||||
c.Magic(b'CRAG'),
|
'header_size' / c.Int32ul, # 28 in XY, 36 in SUMO
|
||||||
c.ULInt32('header_size'), # 28 in XY, 36 in SUMO
|
'byte_order' / c.Const(c.Int16ul, 0xfeff),
|
||||||
c.Const(c.ULInt16('byte_order'), 0xfeff),
|
'mystery1' / c.Int16ul, # 0x0400 in XY, 0x0600 in SUMO
|
||||||
c.ULInt16('mystery1'), # 0x0400 in XY, 0x0600 in SUMO
|
|
||||||
#c.Const(c.ULInt32('chunks_ct'), 4),
|
#c.Const(c.ULInt32('chunks_ct'), 4),
|
||||||
c.ULInt32('chunks_ct'),
|
'chunks_ct' / c.Int32ul,
|
||||||
c.ULInt32('data_offset'),
|
'data_offset' / c.Int32ul,
|
||||||
c.ULInt32('garc_length'),
|
'garc_length' / c.Int32ul,
|
||||||
c.ULInt32('last_length'),
|
'last_length' / c.Int32ul,
|
||||||
c.Field('unknown_sumo_stuff', lambda ctx: ctx.header_size - 28),
|
'unknown_sumo_stuff' / c.Bytes(lambda ctx: ctx.header_size - 28),
|
||||||
)
|
)
|
||||||
fato_header_struct = c.Struct(
|
fato_header_struct = c.Struct(
|
||||||
'fato_header',
|
c.Const(b'OTAF'),
|
||||||
c.Magic(b'OTAF'),
|
'header_size' / c.Int32ul,
|
||||||
c.ULInt32('header_size'),
|
'count' / c.Int16ul,
|
||||||
c.ULInt16('count'),
|
c.Const(c.Int16ul, 0xffff),
|
||||||
c.Const(c.ULInt16('padding'), 0xffff),
|
'fatb_offsets' / c.Array(c.this.count, c.Int32ul),
|
||||||
c.Array(
|
|
||||||
lambda ctx: ctx.count,
|
|
||||||
c.ULInt32('fatb_offsets'),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
fatb_header_struct = c.Struct(
|
fatb_header_struct = c.Struct(
|
||||||
'fatb_header',
|
c.Const(b'BTAF'),
|
||||||
c.Magic(b'BTAF'),
|
'fatb_length' / c.Int32ul,
|
||||||
c.ULInt32('fatb_length'),
|
'count' / c.Int32ul,
|
||||||
c.ULInt32('count'),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue