mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2024-11-16 11:27:33 -08:00
make gfx.py more convenient from command line
This commit is contained in:
parent
9a64bb1581
commit
3e953ad7b6
@ -593,6 +593,9 @@ class Decompressed:
|
|||||||
|
|
||||||
self.decompress()
|
self.decompress()
|
||||||
|
|
||||||
|
debug = False
|
||||||
|
if debug: print '(' + hex(self.start) + ', ' + hex(self.start + self.address) + ')'
|
||||||
|
|
||||||
# only transpose pic
|
# only transpose pic
|
||||||
self.pic = []
|
self.pic = []
|
||||||
self.animtiles = []
|
self.animtiles = []
|
||||||
@ -1179,17 +1182,11 @@ def decompress_all():
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def export_decompressed(address, mode='horiz', filename = 'de.2bpp', size = None, debug = True):
|
def decompress_from_address(address, mode='horiz', filename = 'de.2bpp', size = None):
|
||||||
"""write decompressed data from an address to a 2bpp file"""
|
"""write decompressed data from an address to a 2bpp file"""
|
||||||
|
|
||||||
if debug: print 'decompressing ' + hex(address)
|
|
||||||
image = Decompressed(rom, mode, size, address)
|
image = Decompressed(rom, mode, size, address)
|
||||||
|
|
||||||
if debug: print 'export to ' + filename + '\n'
|
|
||||||
to_file(filename, image.pic)
|
to_file(filename, image.pic)
|
||||||
|
|
||||||
return image.pic
|
|
||||||
|
|
||||||
|
|
||||||
def decompress_file(filein, fileout, mode = 'horiz', size = None):
|
def decompress_file(filein, fileout, mode = 'horiz', size = None):
|
||||||
f = open(filein, 'rb')
|
f = open(filein, 'rb')
|
||||||
@ -1225,21 +1222,38 @@ def compress_monster_frontpic(id, fileout):
|
|||||||
|
|
||||||
cpr = Compressed(image, mode, 5)
|
cpr = Compressed(image, mode, 5)
|
||||||
|
|
||||||
to_file('old.2bpp', cpr.output)
|
out = '../gfx/frontpics/cpr/' + str(id).zfill(3) + '.cpr'
|
||||||
|
|
||||||
|
to_file(out, cpr.output)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('cmd', nargs='?', metavar='cmd', type=str)
|
parser.add_argument('cmd', nargs='?', metavar='cmd', type=str)
|
||||||
parser.add_argument('addr', nargs='?', metavar='addr', type=str)
|
parser.add_argument('arg1', nargs='?', metavar='arg1', type=str)
|
||||||
parser.add_argument('mode', nargs='?', metavar='mode', type=str)
|
parser.add_argument('arg2', nargs='?', metavar='arg2', type=str)
|
||||||
parser.add_argument('fname', nargs='?', metavar='fname', type=str)
|
parser.add_argument('arg3', nargs='?', metavar='arg3', type=str)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
debug = True
|
||||||
|
|
||||||
if args.cmd == 'de':
|
if args.cmd == 'de':
|
||||||
# python gfx.py de [addr] [fname] [mode]
|
# python gfx.py de [addr] [fileout] [mode]
|
||||||
print hex_dump(export_decompressed(int(args.addr,16), args.mode, args.fname))
|
addr = int(args.arg1,16)
|
||||||
|
fileout = args.arg2
|
||||||
|
mode = args.arg3
|
||||||
|
decompress_from_address(addr, fileout, mode)
|
||||||
|
if debug: print 'decompressed to ' + args.arg2 + ' from ' + hex(int(args.arg1,16)) + '!'
|
||||||
|
|
||||||
|
elif args.cmd == 'cpr':
|
||||||
|
# python gfx.py cpr [filein] [fileout] [mode]
|
||||||
|
filein = args.arg1
|
||||||
|
fileout = args.arg2
|
||||||
|
mode = args.arg3
|
||||||
|
compress_file(filein, fileout, mode)
|
||||||
|
if debug: print 'compressed ' + filein + ' to ' + fileout + '!'
|
||||||
|
|
||||||
else:
|
else:
|
||||||
decompress_all()
|
decompress_all()
|
||||||
print 'decompressed known gfx to ../gfx/!'
|
if debug: print 'decompressed known gfx to ../gfx/!'
|
||||||
|
Loading…
Reference in New Issue
Block a user