diff options
author | Rangi <remy.oukaour+rangi42@gmail.com> | 2019-01-21 16:31:26 -0500 |
---|---|---|
committer | Rangi <remy.oukaour+rangi42@gmail.com> | 2019-01-21 16:31:26 -0500 |
commit | 102c8b74fd4acb1310ec317e8533e16e7ec771cc (patch) | |
tree | 01f81c4a4a9aa422693e03c9347fb9fb5e818f37 | |
parent | 364e4196c624e1c1b95f28c25b5ebe9a17637cdd (diff) |
Iterators
-rw-r--r-- | Allow-tiles-to-have-different-attributes-in-different-blocks-(including-X-and-Y-flip).md | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Allow-tiles-to-have-different-attributes-in-different-blocks-(including-X-and-Y-flip).md b/Allow-tiles-to-have-different-attributes-in-different-blocks-(including-X-and-Y-flip).md index bfee3a1..46c97e7 100644 --- a/Allow-tiles-to-have-different-attributes-in-different-blocks-(including-X-and-Y-flip).md +++ b/Allow-tiles-to-have-different-attributes-in-different-blocks-(including-X-and-Y-flip).md @@ -108,15 +108,14 @@ for palette_map_name in palette_map_names: if not line.startswith('\ttilepal'): continue line = line[len('\ttilepal '):] - colors = list(c.strip() for c in line.split(',')) - bank = colors.pop(0) + colors = (c.strip() for c in line.split(',')) + bank = next(colors) if not reached_vram1 and bank == '1': reached_vram1 = True tile_index = 0x80 for color in colors: tile_attr = color_attrs.get(color, 0) - if tile_index >= 0x80: - tile_attr |= 1 << 3 + tile_attr |= (tile_index >= 0x80) << 3 tile_colors[tile_index] = tile_attr tile_index += 1 @@ -126,7 +125,7 @@ for palette_map_name in palette_map_names: with open(metatiles_name, 'rb') as metatiles: with open(attributes_name, 'wb') as attributes: for block_tiles in iter(lambda: metatiles.read(16), b''): - block_attrs = list(tile_colors.get(t, (t >= 0x80) << 3) + block_attrs = (tile_colors.get(t, (t >= 0x80) << 3) for t in block_tiles) attributes.write(bytes(block_attrs)) metatile_bytes += block_tiles |