Exemplo n.º 1
0
    def parse_palette(data):
        palette = []

        for a, b in iter_in_groups(data, 2):
            palette.append(unpack_color([a, b]))

        return palette
Exemplo n.º 2
0
    def from_bytes(data):
        self = Sprite()

        image_offsets = Sprite.read_offset_list(
            data[int.from_bytes(data[0:4], byteorder="big"):])
        palette_offsets = Sprite.read_offset_list(
            data[int.from_bytes(data[4:8], byteorder="big"):])
        self.max_components = int.from_bytes(data[8:0xC], byteorder="big")
        self.num_variations = int.from_bytes(data[0xC:0x10], byteorder="big")
        animation_offsets = Sprite.read_offset_list(data[0x10:])

        for offset in palette_offsets:
            # 16 colors
            color_data = data[offset:offset + 16 * 2]
            self.palettes.append(
                [unpack_color(c) for c in iter_in_groups(color_data, 2)])

        for offset in image_offsets:
            img = Image.from_bytes(data[offset:], data)
            self.images.append(img)

        for offset in animation_offsets:
            anim = []

            for comp_offset in Sprite.read_offset_list(data[offset:]):
                comp = Component.from_bytes(data[comp_offset:], data)
                anim.append(comp)

            self.animations.append(anim)

        return self
Exemplo n.º 3
0
    def parse_palette(self, rom_bytes):
        data = rom_bytes[self.rom_start:self.rom_end]
        palette = []

        for a, b in iter_in_groups(data, 2):
            palette.append(unpack_color([a, b]))

        return palette
Exemplo n.º 4
0
    def from_bytes(data, sprite_data):
        self = Component()

        commands_offset = int.from_bytes(data[0:4], byteorder="big")
        commands_size = int.from_bytes(data[4:6], byteorder="big") # size in bytes, not length!
        commands_data = sprite_data[commands_offset : commands_offset + commands_size]
        self.commands = [int.from_bytes(d[0:2], byteorder="big") for d in iter_in_groups(commands_data, 2)]

        self.x = int.from_bytes(data[6:8], byteorder="big", signed=True)
        self.y = int.from_bytes(data[8:10], byteorder="big", signed=True)
        self.z = int.from_bytes(data[10:12], byteorder="big", signed=True)

        return self