mirror of
https://github.com/pret/pokemon-reverse-engineering-tools.git
synced 2026-08-09 10:47:24 -05:00
map_editor: read rgb macros instead of binary data for palettes
also fix tileset graphics handling
This commit is contained in:
parent
b5c3ef9b4f
commit
d996bcf18e
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user