Example #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
Example #2
0
def palettes(sprite):
	data = bytearray()

	all = lambda p: p
	all_rev = lambda p: p[::-1]
	first = lambda p: p[:1]
	index_3 = lambda p: p[3:4]
	first_14 = lambda p: p[:14]
	first_15 = lambda p: p[:15]
	last = lambda p: p[-1:]
	last_15 = lambda p: p[-15:]

	palette_manifest = [
		("power",  "standard",    first,  [(first_15,range(1))]),
		("varia",  "standard",    first,  [(first_15,range(1))]),
		("gravity","standard",    first,  [(first_15,range(1))]),
		("power",  "loader",      all,    [(first_15,[0x00,0x01,0x48,0x49,0x4E,0x4F,0x54,0x55,0x58])]),
		("varia",  "loader",      all,    [(first_15,[0x00,0x01,0x48,0x49,0x4E,0x4F,0x54,0x55,0x58])]),
		("gravity","loader",      all,    [(first_15,[0x00,0x01,0x48,0x49,0x4E,0x4F,0x54,0x55,0x58])]),
		("power",  "heat",        all,    [(last_15, range(16))]),
		("varia",  "heat",        all,    [(last_15, range(16))]),
		("gravity","heat",        all,    [(last_15, range(16))]),
		("power",  "charge",      all,    [(first_15,range(8))]),
		("varia",  "charge",      all,    [(first_15,range(8))]),
		("gravity","charge",      all,    [(first_15,range(8))]),
		("power",  "speed boost", all,    [(first_15,range(4))]),
		("varia",  "speed boost", all,    [(first_15,range(4))]),
		("gravity","speed boost", all,    [(first_15,range(4))]),
		("power",  "speed squat", all,    [(first_15,range(4))]),
		("varia",  "speed squat", all,    [(first_15,range(4))]),
		("gravity","speed squat", all,    [(first_15,range(4))]),
		("power",  "shinespark",  all,    [(first_15,range(4))]),
		("varia",  "shinespark",  all,    [(first_15,range(4))]),
		("gravity","shinespark",  all,    [(first_15,range(4))]),
		("power",  "screw attack",all,    [(first_15,range(4))]),
		("varia",  "screw attack",all,    [(first_15,range(4))]),
		("gravity","screw attack",all,    [(first_15,range(4))]),
		("power",  "flash",       all,    [(first_15,range(6))]),
		("power",  "death",       all,    [(first_15,range(9))]),
		("power",  "hyper",       all_rev,[(first_15,range(10))]),
		("power",  "sepia",       first,  [(first_15,range(1))]),
		("power",  "sepia hurt",  first,  [(first_15,range(1))]),
		("power",  "xray",        all,    [(index_3, range(3))]),
		("power",  "door",        first,  [(index_3, range(1))]),
		("power",  "file select", first,  [(first_15,range(1))]),
		("ship",   "intro",       first,  [(first_15,range(1))]),
		("ship",   "outro",       all,    [(first_15,range(16))]),
		("ship",   "standard",    all,    [(first_14,range(1)),      # first 14 colors
		                                   (last,    range(14))]),   # 15th color is underglow
	]

	for category,pose,palette_set,data_sets in palette_manifest:
		palettes = [pal for _,pal in palette_set(sprite.get_timed_palette(category,pose))]
		for color_set,indices in data_sets:
			colors_555 = [common.convert_to_555(color_set(pal)) for pal in palettes]
			data.extend(itertools.chain.from_iterable([common.as_u16(c) for i in indices for c in colors_555[i]]))

	return data
Example #3
0
	def get_binary_palettes(self):
		raw_palette_data = bytearray()
		colors_555 = common.convert_to_555(self.master_palette)

		# Mail and bunny palettes
		raw_palette_data.extend(itertools.chain.from_iterable([common.as_u16(c) for i in range(4) for c in colors_555[0x10*i+1:0x10*i+0x10]]))

		# Glove colors
		raw_palette_data.extend(itertools.chain.from_iterable([common.as_u16(colors_555[0x10*i+0x10]) for i in range(2)]))

		return raw_palette_data