diff options
author | yenatch <yenatch@gmail.com> | 2013-12-23 03:40:04 -0500 |
---|---|---|
committer | yenatch <yenatch@gmail.com> | 2013-12-23 03:40:04 -0500 |
commit | 9dc5b70cac00b23b8f61d485bd938a7adc30abf8 (patch) | |
tree | 349b38b8292b870d46f401e039afb6afc95b9ab6 | |
parent | d996bcf18e89826563e548014bbddddc677af229 (diff) |
map_gfx: read rgb macros for palettes
-rw-r--r-- | pokemontools/map_gfx.py | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/pokemontools/map_gfx.py b/pokemontools/map_gfx.py index 77e7d56..b06f0df 100644 --- a/pokemontools/map_gfx.py +++ b/pokemontools/map_gfx.py @@ -178,29 +178,9 @@ def read_palettes(time_of_day=1, config=config): filename = "{}.pal".format(actual_time_of_day) filepath = os.path.join(config.palette_dir, filename) - num_colors = 4 - color_length = 2 - palette_length = num_colors * color_length - - pals = bytearray(open(filepath, "rb").read()) - num_pals = len(pals) / palette_length - - for pal in xrange(num_pals): - palettes += [[]] - - for color in xrange(num_colors): - i = pal * palette_length - i += color * color_length - word = pals[i] + pals[i+1] * 0x100 - - palettes[pal] += [[ - c & 0x1f for c in [ - word >> 0, - word >> 5, - word >> 10, - ] - ]] - + lines = open(filepath, "r").readlines() + colors = gfx.read_rgb_macros(lines) + palettes = [colors[i:i+4] for i in xrange(0, len(colors), 4)] return palettes def load_sprite_image(address, config=config): |