From 6ba758aa53bbf14e2c152fd88f786a501f6bb029 Mon Sep 17 00:00:00 2001 From: yenatch Date: Wed, 12 Jun 2013 21:31:45 -0400 Subject: expand shortened palettes rather than keep up inconsistent palette formats, just incbin a portion of each --- extras/gfx.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'extras/gfx.py') diff --git a/extras/gfx.py b/extras/gfx.py index 03d5e49a2..1667bb424 100644 --- a/extras/gfx.py +++ b/extras/gfx.py @@ -1532,6 +1532,26 @@ def decompress_frontpic_anim(lz_file): lz = open(lz_file, 'rb').read() to_file(Decompressed(lz).animtiles, 'tiles.2bpp') +def expand_pic_palettes(): + """ + Add white and black to palette files with fewer than 4 colors. + + Pokemon Crystal only defines two colors for a pic palette to + save space, filling in black/white at runtime. + Instead of managing palette files of varying length, black + and white are added to pic palettes and excluded from incbins. + """ + for root, dirs, files in os.walk('../gfx/'): + if 'gfx/pics' in root or 'gfx/trainers' in root: + for name in files: + if os.path.splitext(name)[1] == '.pal': + filename = os.path.join(root, name) + palette = bytearray(open(filename, 'rb').read()) + w = bytearray([0xff, 0x7f]) + b = bytearray([0x00, 0x00]) + if len(palette) == 4: + with open(filename, 'wb') as out: + out.write(w + palette + b) if __name__ == "__main__": debug = False -- cgit v1.2.3