Beispiel #1
0
    def write_uncomp_data(self, fp):
        if self.comp_type == fake:
            fp.write(self.data[4:])
        elif self.comp_type == lz77:
            fp.write(lzss3.decompress_bytes(self.data))
        else:
#            print('error: 0x%X %s compression is not supported.' % (self.offset, CompType[self.comp_type]))
            raise CompTypeError(self.offset, self.comp_type)
Beispiel #2
0
        exit()

    rom_dir, output_dir = sys.argv[1:]

    # Create the necessary directory structure
    os.makedirs(os.path.join(output_dir, 'female'), exist_ok=True)
    os.makedirs(os.path.join(output_dir, 'right'), exist_ok=True)

    # Parse the icons
    icon_path = os.path.join(rom_dir, 'romfs', 'a', '0', '9', '3')

    with open(icon_path, 'rb') as icon_file:
        icons = garc.chomp(icon_file)

    icons = [
        Icon(lzss3.decompress_bytes(icon), index)
        for index, [icon] in enumerate(icons)
    ]

    # Map icons to Pokémon and save them all
    code_bin_path = os.path.join(rom_dir, 'exefs', 'code.bin')

    with open('forms.yaml') as form_list:
        form_names = yaml.load(form_list)

    with open(code_bin_path, 'rb') as code_bin:
        for pokemon in range(1, 722):
            pokemon_icons = map_icons(pokemon, icons, code_bin)
            save_icons(pokemon_icons, output_dir, pokemon,
                       form_names.get(pokemon))
Beispiel #3
0
from pathlib import Path
import pytest
# reference implementation
from lzss3 import decompress_bytes

TEST_FILES = []
TEST_FILE_DATA = dict()
TEST_FILE_DATA_UNCOMP = dict()
for path in (Path(__file__).parent / "files").glob("*.LZ"):
    with path.open("rb") as f:
        TEST_FILES.append(pytest.param(path.name, id='/'))
        TEST_FILE_DATA[path.name] = f.read()
        TEST_FILE_DATA_UNCOMP[path.name] = decompress_bytes(
            TEST_FILE_DATA[path.name])
Beispiel #4
0
        exit(1)

    with open(garc_filename, 'rb') as garc_file:
        garc = chomp(garc_file)

    with open(dump_filename, 'w') as dump_file:
        for file_num, file_ in enumerate(garc):
            for subfile_num, subfile in enumerate(file_):
                # if not file_num == subfile_num == 0:
                #     dump_file.write('\n\n')

                lzssed = False

                if subfile and subfile[0] in [0x10, 0x11]:
                    try:
                        subfile = lzss3.decompress_bytes(subfile)
                        lzssed = True
                    except:
                        pass

                print(' '.join('{:02X}'.format(b) for b in subfile), file=dump_file)

                # dump_file.write('### FILE {}.{}{}\n'.format(file_num,
                #     subfile_num, ' (LZSS decompressed)' if lzssed else ''))
                # dump_file.flush()

                # with subprocess.Popen(['xxd'], stdin=subprocess.PIPE,
                #   stdout=dump_file) as xxd:
                #     xxd.communicate(subfile)

                # dump_file.flush()
Beispiel #5
0
def test_compress(file):
    assert TEST_FILE_DATA_UNCOMP[file] == decompress_bytes(
        bytes(nlzss11.compress(TEST_FILE_DATA_UNCOMP[file])))