summaryrefslogtreecommitdiff
path: root/gfx.py
diff options
context:
space:
mode:
authoryenatch <yenatch@gmail.com>2013-06-12 21:31:45 -0400
committeryenatch <yenatch@gmail.com>2013-06-12 21:40:37 -0400
commit3cadc09cc031fdb37d3703b4df56d6021dab01f5 (patch)
treebdc426a9590122786030af243e42a51115958bf8 /gfx.py
parent7ccbbcced852f9d4189d3fa4e4b7aaa979b1e105 (diff)
expand shortened palettes
rather than keep up inconsistent palette formats, just incbin a portion of each original-commit-id: 6ba758aa53bbf14e2c152fd88f786a501f6bb029
Diffstat (limited to 'gfx.py')
-rw-r--r--gfx.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/gfx.py b/gfx.py
index 03d5e49..1667bb4 100644
--- a/gfx.py
+++ b/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