CSNG (File Format): Difference between revisions
Jump to navigation
Jump to search
no edit summary
imported>Jackoalan |
imported>Jackoalan No edit summary |
||
Line 170: | Line 170: | ||
<syntaxhighlight lang="python" line="1"> | <syntaxhighlight lang="python" line="1"> | ||
def DecodeDeltaTimeRLE( | def DecodeDeltaTimeRLE(streamIn): | ||
total = 0 | total = 0 | ||
while True: | while True: | ||
term = | term = streamIn.ReadU16() | ||
if term == 0xffff: | if term == 0xffff: | ||
total += 0xffff | total += 0xffff | ||
dummy = | dummy = streamIn.ReadU16() | ||
continue | continue | ||
total += term | total += term | ||
Line 249: | Line 249: | ||
<syntaxhighlight lang="python" line="1"> | <syntaxhighlight lang="python" line="1"> | ||
def DecodeRLE( | def DecodeRLE(streamIn): | ||
# high-bit shift-trigger RLE, limited to 2 bytes | # high-bit shift-trigger RLE, limited to 2 bytes | ||
term = | term = streamIn.ReadU8() | ||
total = term & 0x7f | total = term & 0x7f | ||
if term & 0x80: | if term & 0x80: | ||
total = total * 256 + | total = total * 256 + streamIn.ReadU8() | ||
return total | return total | ||
def DecodeContinuousRLE( | def DecodeContinuousRLE(streamIn, isValue): | ||
total = 0 | total = 0 | ||
while True: | while True: | ||
# 1-2 byte RLE accumulated within continuable RLE | # 1-2 byte RLE accumulated within continuable RLE | ||
term = DecodeRLE( | term = DecodeRLE(streamIn) | ||
if term == 0x8000: | if term == 0x8000: | ||
total += 0xffff | total += 0xffff |