diff options
author | yenatch <yenatch@gmail.com> | 2013-12-23 03:32:50 -0500 |
---|---|---|
committer | yenatch <yenatch@gmail.com> | 2013-12-23 03:32:50 -0500 |
commit | d996bcf18e89826563e548014bbddddc677af229 (patch) | |
tree | 6c092310e3a7c2e8a28266a61a87993ac080932a /pokemontools/map_editor.py | |
parent | b5c3ef9b4fbbc14d9baa125b10ebf4d96a79de7e (diff) |
map_editor: read rgb macros instead of binary data for palettes
also fix tileset graphics handling
Diffstat (limited to 'pokemontools/map_editor.py')
-rw-r--r-- | pokemontools/map_editor.py | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/pokemontools/map_editor.py b/pokemontools/map_editor.py index 43042cb..b9a6b61 100644 --- a/pokemontools/map_editor.py +++ b/pokemontools/map_editor.py @@ -445,7 +445,7 @@ class Tileset: def get_tiles(self): filename = self.get_tileset_gfx_filename() if not os.path.exists(filename): - gfx.to_png(filename.replace('.png','.2bpp'), filename) + gfx.export_lz_to_png(filename.replace('.png','.lz')) self.img = Image.open(filename) self.img.width, self.img.height = self.img.size self.tiles = [] @@ -505,30 +505,9 @@ class Tileset: self.palettes = get_palettes(filename) def get_palettes(filename): - pals = bytearray(open(filename, 'rb').read()) - - num_colors = 4 - color_length = 2 - - palette_length = num_colors * color_length - - num_pals = len(pals) / palette_length - - palettes = [] - 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(filename, 'r').readlines() + colors = gfx.read_rgb_macros(lines) + palettes = [colors[i:i+4] for i in xrange(0, len(colors), 4)] return palettes def get_available_maps(config=config): |