mirror of
https://github.com/pret/pokemon-reverse-engineering-tools.git
synced 2026-08-26 12:14:10 -05:00
Accidentally moved get_pic_animation out of gfx.py.
This commit is contained in:
@@ -288,45 +288,6 @@ def rip_bulk_gfx(rom, dest='gfx', crystal=True):
|
|||||||
rip_compressed_misc (rom, dest=os.path.join(dest, 'misc'))
|
rip_compressed_misc (rom, dest=os.path.join(dest, 'misc'))
|
||||||
|
|
||||||
|
|
||||||
def get_pic_animation(tmap, w, h):
|
|
||||||
"""
|
|
||||||
Generate pic animation data from a combined tilemap of each frame.
|
|
||||||
"""
|
|
||||||
frame_text = ''
|
|
||||||
bitmask_text = ''
|
|
||||||
|
|
||||||
frames = list(split(tmap, w * h))
|
|
||||||
base = frames.pop(0)
|
|
||||||
bitmasks = []
|
|
||||||
|
|
||||||
for i in xrange(len(frames)):
|
|
||||||
frame_text += '\tdw .frame{}\n'.format(i + 1)
|
|
||||||
|
|
||||||
for i, frame in enumerate(frames):
|
|
||||||
bitmask = map(operator.ne, frame, base)
|
|
||||||
if bitmask not in bitmasks:
|
|
||||||
bitmasks.append(bitmask)
|
|
||||||
which_bitmask = bitmasks.index(bitmask)
|
|
||||||
|
|
||||||
mask = iter(bitmask)
|
|
||||||
masked_frame = filter(lambda _: mask.next(), frame)
|
|
||||||
|
|
||||||
frame_text += '.frame{}\n'.format(i + 1)
|
|
||||||
frame_text += '\tdb ${:02x} ; bitmask\n'.format(which_bitmask)
|
|
||||||
if masked_frame:
|
|
||||||
frame_text += '\tdb {}\n'.format(', '.join(
|
|
||||||
map('${:02x}'.format, masked_frame)
|
|
||||||
))
|
|
||||||
|
|
||||||
for i, bitmask in enumerate(bitmasks):
|
|
||||||
bitmask_text += '; {}\n'.format(i)
|
|
||||||
for byte in split(bitmask, 8):
|
|
||||||
byte = int(''.join(map(int.__repr__, reversed(byte))), 2)
|
|
||||||
bitmask_text += '\tdb %{:08b}\n'.format(byte)
|
|
||||||
|
|
||||||
return frame_text, bitmask_text
|
|
||||||
|
|
||||||
|
|
||||||
def dump_pic_animations(addresses={'bitmasks': 'BitmasksPointers', 'frames': 'FramesPointers'}, pokemon=pokemon_constants, rom=None):
|
def dump_pic_animations(addresses={'bitmasks': 'BitmasksPointers', 'frames': 'FramesPointers'}, pokemon=pokemon_constants, rom=None):
|
||||||
"""
|
"""
|
||||||
The code to dump pic animations from rom is mysteriously absent.
|
The code to dump pic animations from rom is mysteriously absent.
|
||||||
|
|||||||
@@ -508,6 +508,45 @@ def convert_2bpp_to_png(image, **kwargs):
|
|||||||
return width, height, palette, greyscale, bitdepth, px_map
|
return width, height, palette, greyscale, bitdepth, px_map
|
||||||
|
|
||||||
|
|
||||||
|
def get_pic_animation(tmap, w, h):
|
||||||
|
"""
|
||||||
|
Generate pic animation data from a combined tilemap of each frame.
|
||||||
|
"""
|
||||||
|
frame_text = ''
|
||||||
|
bitmask_text = ''
|
||||||
|
|
||||||
|
frames = list(split(tmap, w * h))
|
||||||
|
base = frames.pop(0)
|
||||||
|
bitmasks = []
|
||||||
|
|
||||||
|
for i in xrange(len(frames)):
|
||||||
|
frame_text += '\tdw .frame{}\n'.format(i + 1)
|
||||||
|
|
||||||
|
for i, frame in enumerate(frames):
|
||||||
|
bitmask = map(operator.ne, frame, base)
|
||||||
|
if bitmask not in bitmasks:
|
||||||
|
bitmasks.append(bitmask)
|
||||||
|
which_bitmask = bitmasks.index(bitmask)
|
||||||
|
|
||||||
|
mask = iter(bitmask)
|
||||||
|
masked_frame = filter(lambda _: mask.next(), frame)
|
||||||
|
|
||||||
|
frame_text += '.frame{}\n'.format(i + 1)
|
||||||
|
frame_text += '\tdb ${:02x} ; bitmask\n'.format(which_bitmask)
|
||||||
|
if masked_frame:
|
||||||
|
frame_text += '\tdb {}\n'.format(', '.join(
|
||||||
|
map('${:02x}'.format, masked_frame)
|
||||||
|
))
|
||||||
|
|
||||||
|
for i, bitmask in enumerate(bitmasks):
|
||||||
|
bitmask_text += '; {}\n'.format(i)
|
||||||
|
for byte in split(bitmask, 8):
|
||||||
|
byte = int(''.join(map(int.__repr__, reversed(byte))), 2)
|
||||||
|
bitmask_text += '\tdb %{:08b}\n'.format(byte)
|
||||||
|
|
||||||
|
return frame_text, bitmask_text
|
||||||
|
|
||||||
|
|
||||||
def export_png_to_2bpp(filein, fileout=None, palout=None, **kwargs):
|
def export_png_to_2bpp(filein, fileout=None, palout=None, **kwargs):
|
||||||
|
|
||||||
arguments = {
|
arguments = {
|
||||||
|
|||||||
Reference in New Issue
Block a user