Exemplo n.º 1
0
    def inject_into_ROM(self, rom):
        #should work for the combo rom, VT rando, and the (J) rom.  Not sure about the (U) rom...maybe?

        #the sheet needs to be placed directly into address $108000-$10F000
        for i, row in enumerate(
                itertools.chain(ascii_uppercase,
                                ["AA", "AB"])):  #over all 28 rows of the sheet
            for column in range(8):  #over all 8 columns
                image_name = f"{row}{column}"
                if image_name == "AB7":
                    #AB7 is special, because the palette block sits there in the PNG, so this can't be actually used
                    image_name = "null_block"
                raw_image_data = common.convert_to_4bpp(
                    self.images[image_name], (0, 0), (0, 0, 16, 16), None)

                rom.bulk_write_to_snes_address(
                    0x108000 + 0x400 * i + 0x40 * column,
                    raw_image_data[:0x40], 0x40)
                rom.bulk_write_to_snes_address(
                    0x108200 + 0x400 * i + 0x40 * column,
                    raw_image_data[0x40:], 0x40)

        #the palettes need to be placed directly into address $1BD308-$1BD380, not including the transparency or gloves colors
        converted_palette = common.convert_to_555(self.master_palette)
        for i in range(4):
            rom.write_to_snes_address(
                0x1BD308 + 0x1E * i,
                converted_palette[0x10 * i + 1:0x10 * i + 0x10], 0x0F * "2")
        #the glove colors are placed into $1BEDF5-$1BEDF8
        for i in range(2):
            rom.write_to_snes_address(0x1BEDF5 + 0x02 * i,
                                      converted_palette[0x10 + 0x10 * i], 2)

        return rom
Exemplo n.º 2
0
def death_bank(direction, sprite):
    len = 0x3F60
    image = rom_export.compile_death_image(direction, sprite)
    return bytes(
        itertools.chain.from_iterable(
            common.convert_to_4bpp(image, (0, 0), (0, 16 * i, 128, 16 *
                                                   (i + 1)), None)
            for i in range(16)))[:len]
Exemplo n.º 3
0
def file_select(sprite):
    file_select_sprites = Image.new("P", (128, 24), 0)

    for image_name, src, dest in [
        ("file_select_head", None, (0, 0)),
        ("file_select_head1", None, (24, 0)),
        ("file_select_head2", None, (48, 0)),
        ("file_select_visor", None, (72, 0)),
        ("file_select_visor1", None, (88, 0)),
        ("file_select_visor2", None, (104, 0)),
        ("file_select_visor3", None, (72, 8)),
        ("file_select_visor4", None, (88, 8)),
        ("file_select_cursor_array", (0, 24, 8, 32), (112, 16)),
        ("file_select_cursor_array", (0, 16, 8, 24), (112, 8)),
        ("file_select_cursor_array", (0, 8, 8, 16), (120, 0)),
        ("file_select_cursor_array", (8, 24, 16, 32), (120, 8)),
        ("file_select_cursor_array", (8, 16, 16, 24), (120, 16)),
        ("file_select_piping", (0, 0, 24, 8), (72, 16)),  # Top
        ("file_select_piping", (16, 8, 24, 24), (104, 8)),  # Side
        ("file_select_piping", (0, 16, 8, 24), (96, 16)),  # Corner
    ]:
        source_image = sprite.images[image_name]
        source_image = source_image.crop(src) if src else source_image
        file_select_sprites.paste(source_image, dest)

    cursor_array = sprite.images["file_select_cursor_array"]
    file_select_missile = cursor_array.crop((0, 0, 8, 8))
    file_select_missile_head = cursor_array.crop((8, 8, 16, 16))

    data = bytearray()
    # Due to how convert_to_4bpp package the data we must first get a whole sheet row, then extract the third row (first 0x200 bytes)
    data.extend(
        common.convert_to_4bpp(file_select_sprites, (0, 0), (0, 0, 128, 16),
                               None))
    data.extend(
        common.convert_to_4bpp(file_select_sprites, (0, 0), (0, 16, 128, 32),
                               None)[:0x200])
    data.extend(
        common.convert_to_4bpp(file_select_missile, (0, 0), (0, 0, 8, 8),
                               None))
    data.extend(
        common.convert_to_4bpp(file_select_missile_head, (0, 0), (0, 0, 8, 8),
                               None))
    return data
Exemplo n.º 4
0
	def get_binary_sprite_sheet(self):
		top_half_of_rows = bytearray()
		bottom_half_of_rows = bytearray()

		# 28 rows, 8 columns
		for image_name in [f"{row}{column}" for row in itertools.chain(ascii_uppercase, ["AA","AB"]) for column in range(8)]:
			# AB7 holds the palette block so use null_block instead
			image_name = image_name if image_name != "AB7" else "null_block"
			raw_image = common.convert_to_4bpp(self.images[image_name],(0,0),(0,0,16,16),None)
			top_half_of_rows += bytes(raw_image[:0x40])
			bottom_half_of_rows += bytes(raw_image[0x40:])

		return bytes(b for row_offset in range(0,len(top_half_of_rows),0x200) \
					   for b in top_half_of_rows[row_offset:row_offset+0x200]+bottom_half_of_rows[row_offset:row_offset+0x200])