summaryrefslogtreecommitdiff
path: root/pokemontools/map_editor.py
diff options
context:
space:
mode:
authorBryan Bishop <kanzure@gmail.com>2013-12-28 17:04:15 -0800
committerBryan Bishop <kanzure@gmail.com>2013-12-28 17:04:15 -0800
commit6ec167512e05c3541308fbbaa7e91cf53942e533 (patch)
tree85350b4414bd03cd3155a171563f0fce0b6d35ad /pokemontools/map_editor.py
parentf0aaf3cd568c485af40690ce0f18a6cd456ed02e (diff)
parent70cd4f7c00b33a398ed7af071773c06ca335c105 (diff)
Merge pull request #62 from yenatch/battle-animations
* event command macro storetext actually took one param * PointerLabel{Before,After}Bank now take a label instead of the redundant BANK(label), label * use the from_asm() method for all macros * no more macro logic in the preprocessor * read and write RGB macros for palettes instead of binary chunks * battle animation macros
Diffstat (limited to 'pokemontools/map_editor.py')
-rw-r--r--pokemontools/map_editor.py29
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):