"""
set_palette.py

automatically generates a script to set the palette for the unset palette
colors (i.e. entries 16-63)

see ./color_stuff folder to get an understanding of how the colors were
automatically generated.

palette.txt contains the colors we're going to use
"""

from datetime import date as date


OFFSET = 16

header = """# set-palette.scr

# This script sets the palette colors 16--63, which by default are a boring
# grey, to something colorful and exciting.

# This script file was automatically generated by set_palette.py.

# Ryan Matlock
# {date}

""".format(date=date.today())

colors = []
with open("palette.txt") as p:
    for color in p:
        colors.append(color.strip())

with open("set-palette.scr", "w") as sp:
    sp.write(header)
    for (i, color) in enumerate(colors):
        # the "... C8{} ..." sets an alpha layer transparency of C8, which is
        # apparently pretty standard
        sp.write("SET PALETTE {} 0xC8{};\n".format(i + OFFSET, color))
