import struct def read_int(fp): return struct.unpack(" str: s = "" c = read_byte(fp) while c != 0x00: s += chr(c) c = read_byte(fp) return s def decompress(compressed_bytes, original_size: int): i = 0 j = 0 dec_byte = 0 dec_bits = 8 buff_start = 0xFEE res = bytearray(original_size) if original_size == 0: return res while j < original_size: if dec_bits == 8: dec_byte = compressed_bytes[i] i += 1 dec_bits = 0 if (dec_byte >> dec_bits & 1) == 0: dec_pos = ((compressed_bytes[i] + ( (compressed_bytes[i + 1] & 0xF0) << 4) - buff_start - j) & 0xFFF) - 0x1000 + j dec_len = (compressed_bytes[i + 1] & 0xF) + 3 i += 2 while dec_len > 0: if dec_pos >= 0: res[j] = res[dec_pos] else: res[j] = 32 j += 1 dec_pos += 1 dec_len -= 1 else: res[j] = compressed_bytes[i] i += 1 j += 1 dec_bits += 1 return res def read_int_and_print(n, b): a = read_int(b) print("%s=%s" % (n, a)) return a def read_float_and_print(n, b): a = read_float(b) print("%s=%s" % (n, a)) return a def read_byte_and_print(n, b): a = read_byte(b) print("%s=%s" % (n, a)) return a def read_short_and_print(n, b): a = read_short(b) print("%s=%s" % (n, a)) return a def read_string_until_none_and_print(n, b): s = read_string_until_none(b) print("%s=%s" % (n, s)) return s