diff options
author | Sanky <gsanky@gmail.com> | 2013-02-02 23:13:32 +0100 |
---|---|---|
committer | Sanky <gsanky@gmail.com> | 2013-02-02 23:20:50 +0100 |
commit | 4089cf486d83d78fddaab98316952e1bbeaafd47 (patch) | |
tree | f2721b81775a3e450e1a301a4679c9d6159c22b3 /gfx.py | |
parent | 43546fd07ac588be694c697873a642c5a2cc8c1d (diff) | |
parent | 1e893fae740cd9f82ead9adcb6f5c1ccb1c6090b (diff) |
Merge https://github.com/kanzure/pokecrystal
Conflicts:
constants.asm
extras/crystal.py
main.asm
original-commit-id: 7df002c3e20f1b728b1d29a877c3731d4867f502
Diffstat (limited to 'gfx.py')
-rw-r--r-- | gfx.py | 58 |
1 files changed, 44 insertions, 14 deletions
@@ -1043,14 +1043,16 @@ def decompress_monsters(type = front): # decompress monster = decompress_monster_by_id(id, type) if monster != None: # no unowns here - filename = str(id+1).zfill(3) + '.2bpp' # 001.2bpp if not type: # front - folder = '../gfx/frontpics/' + filename = 'front.2bpp' + folder = '../gfx/pics/' + str(id+1).zfill(3) + '/' to_file(folder+filename, monster.pic) - folder = '../gfx/anim/' + filename = 'tiles.2bpp' + folder = '../gfx/pics/' + str(id+1).zfill(3) + '/' to_file(folder+filename, monster.animtiles) else: # back - folder = '../gfx/backpics/' + filename = 'back.2bpp' + folder = '../gfx/pics/' + str(id+1).zfill(3) + '/' to_file(folder+filename, monster.pic) @@ -1073,14 +1075,16 @@ def decompress_unowns(type = front): # decompress unown = decompress_unown_by_id(letter, type) - filename = str(unown_dex).zfill(3) + chr(ord('a') + letter) + '.2bpp' # 201a.2bpp if not type: # front - folder = '../gfx/frontpics/' + filename = 'front.2bpp' + folder = '../gfx/pics/' + str(unown_dex).zfill(3) + chr(ord('a') + letter) + '/' to_file(folder+filename, unown.pic) + filename = 'tiles.2bpp' folder = '../gfx/anim/' to_file(folder+filename, unown.animtiles) else: # back - folder = '../gfx/backpics/' + filename = 'back.2bpp' + folder = '../gfx/pics/' + str(unown_dex).zfill(3) + chr(ord('a') + letter) + '/' to_file(folder+filename, unown.pic) @@ -1255,8 +1259,8 @@ def compress_file(filein, fileout, mode = 'horiz'): def compress_monster_frontpic(id, fileout): mode = 'vert' - fpic = '../gfx/frontpics/' + str(id).zfill(3) + '.2bpp' - fanim = '../gfx/anim/' + str(id).zfill(3) + '.2bpp' + fpic = '../gfx/pics/' + str(id).zfill(3) + '/front.2bpp' + fanim = '../gfx/pics/' + str(id).zfill(3) + '/tiles.2bpp' pic = open(fpic, 'rb').read() anim = open(fanim, 'rb').read() @@ -1264,7 +1268,7 @@ def compress_monster_frontpic(id, fileout): lz = Compressed(image, mode, 5) - out = '../gfx/frontpics/lz/' + str(id).zfill(3) + '.lz' + out = '../gfx/pics/' + str(id).zfill(3) + '/front.lz' to_file(out, lz.output) @@ -1283,6 +1287,28 @@ def get_uncompressed_gfx(start, num_tiles, filename): +def hex_to_rgb(word): + red = word & 0b11111 + word >>= 5 + green = word & 0b11111 + word >>= 5 + blue = word & 0b11111 + return (red, green, blue) + +def grab_palettes(address, length = 0x80): + output = '' + for word in range(length/2): + color = ord(rom[address+1])*0x100 + ord(rom[address]) + address += 2 + color = hex_to_rgb(color) + red = str(color[0]).zfill(2) + green = str(color[1]).zfill(2) + blue = str(color[2]).zfill(2) + output += '\tRGB '+red+', '+green+', '+blue + output += '\n' + return output + + if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('cmd', nargs='?', metavar='cmd', type=str) @@ -1317,7 +1343,11 @@ if __name__ == "__main__": # python gfx.py un [address] [num_tiles] [filename] get_uncompressed_gfx(int(args.arg1,16), int(args.arg2), args.arg3) - else: - # python gfx.py - decompress_all() - if debug: print 'decompressed known gfx to ../gfx/!' + elif args.cmd == 'pal': + # python gfx.py pal [address] [length] + print grab_palettes(int(args.arg1,16), int(args.arg2)) + + #else: + ## python gfx.py + #decompress_all() + #if debug: print 'decompressed known gfx to ../gfx/!' |